Module: Octonaut::Helpers

Included in:
Octonaut
Defined in:
lib/octonaut/helpers.rb

Instance Method Summary collapse

Instance Method Details

#open(resource, relation = 'html') ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/octonaut/helpers.rb', line 4

def open(resource, relation = 'html')
  link_field = case relation
               when 'self'
                 'url'
               when /_url$/
                 relation
               else
                 "#{relation}_url"
               end

  url = resource.send(link_field.to_sym)

  Launchy.open url
end