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

Instance Method Details

#card_path(rel_path) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/card/env/location.rb', line 21

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 =~ /^\//
    rel_path
  else
    "#{Card.config.relative_url_root}/#{rel_path}"
  end
end

#card_url(rel) ⇒ Object



33
34
35
36
37
38
39
# File 'lib/card/env/location.rb', line 33

def card_url rel
  if rel =~ /^https?\:/
    rel
  else
    "#{Card::Env[:protocol]}#{Card::Env[:host]}#{card_path rel}"
  end
end

#page_path(title, opts = {}) ⇒ Object

TESTME



10
11
12
13
14
15
16
17
18
19
# File 'lib/card/env/location.rb', line 10

def page_path title, opts={}
  unless title.is_a? Card::Name
    Rails.logger.warn "Pass only Card::Name to page_path " \
                      "(#{title} = #{title.class})"
  end
  format = opts[:format] ? ".#{opts.delete(:format)}" : ""
  action = opts[:action] ? "#{opts.delete(:action)}/" : ""
  query  = opts.present? ? "?#{opts.to_param}" : ""
  card_path "#{action}#{title.to_name.url_key}#{format}#{query}"
end