Module: Tight::Engine::Url

Defined in:
lib/tight-engine/url.rb

Instance Method Summary collapse

Instance Method Details

#se_url(obj, method = :show, opts = {}) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/tight-engine/url.rb', line 4

def se_url( obj, method = :show, opts = {} )
  if method.kind_of? Hash
    opts = method
    method = :show
  end
  url = case obj
  when NewsArticle
    '/news' / method / obj.slug
  when FormsCard
    '/forms' / method / obj.slug
  when Page
    obj.path
  else
    swift.module_root ? swift.module_root / method / obj.slug : '/'
  end
  if opts[:absolute]
    absolute_url url
  else
    url
  end
end