Module: Card::Env::Location
- Extended by:
- Location
- Included in:
- Location, Success, Format, Set::Abstract::AssetOutputter, CardController, CarrierWave::FileCardUploader
- Defined in:
- card/lib/card/env/location.rb
Instance Method Summary collapse
-
#card_path(rel_path) ⇒ Object
card_path makes a relative path site-absolute (if not already) card_url makes it a full url (if not already).
-
#card_url(rel) ⇒ Object
-
#cardname_from_url(url) ⇒ Object
-
#relative_url_root ⇒ Object
Instance Method Details
#card_path(rel_path) ⇒ Object
card_path makes a relative path site-absolute (if not already) card_url makes it a full url (if not already)
7 8 9 10 11 12 13 14 15 16 17 |
# File 'card/lib/card/env/location.rb', line 7 def card_path rel_path unless rel_path.is_a? String Rails.logger.warn "Pass only strings to card_path. "\ "(#{rel_path} = #{rel_path.class})" end if rel_path.match? %r{^(https?:)?/} rel_path else "#{relative_url_root}/#{rel_path}" end end |
#card_url(rel) ⇒ Object
19 20 21 |
# File 'card/lib/card/env/location.rb', line 19 def card_url rel rel.match?(/^https?:/) ? rel : "#{Env.origin}#{card_path rel}" end |