Module: Simple::AuthorisationHelper

Defined in:
lib/simple-authorisation/authorisation_helper.rb

Instance Method Summary collapse

Instance Method Details



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/simple-authorisation/authorisation_helper.rb', line 5

def link (route, link_options)
  user = send(options.authorisation_current_user)
  link = Builder::XmlMarkup.new

  if Simple::Authorisation.is_allowed?(route, :user => user,
          :anonymous_user_class => options.authorisation_anonymous_user_class,
          :method => :get)
    main_link = lambda { link.a(:href => route) { |a| a << link_options[:text] }}
    if link_options[:nest]
      link.li {main_link.call}
    else
      main_link.call
    end
  end
  link.target!
end