Module: Card::Env::Location
- Extended by:
- Location
- Included in:
- Location, Success, Format, CarrierWave::FileCardUploader
- Defined in:
- 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
- #protocol_and_host ⇒ 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 '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 =~ %r{^(https?\:)?/} rel_path else "#{Card.config.relative_url_root}/#{rel_path}" end end |
#card_url(rel) ⇒ Object
19 20 21 |
# File 'lib/card/env/location.rb', line 19 def card_url rel rel =~ /^https?\:/ ? rel : "#{protocol_and_host}#{card_path rel}" end |