Module: Acl9::Helpers
- Defined in:
- lib/acl9/helpers.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
-
#show_to(*args, &block) ⇒ Object
Usage:.
Class Method Details
.included(base) ⇒ Object
3 4 5 |
# File 'lib/acl9/helpers.rb', line 3 def self.included(base) base.extend ClassMethods end |
Instance Method Details
#show_to(*args, &block) ⇒ Object
Usage:
<%=show_to(:owner, :supervisor, :of => :account) do %>
<%= 'hello' %>
<% end %>
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/acl9/helpers.rb', line 26 def show_to(*args, &block) user = send(Acl9.config[:default_subject_method]) return if user.nil? has_any = false if args.last.is_a?(Hash) an_obj = args.pop.values.first has_any = args.detect { |role| user.has_role?(role, an_obj) } else has_any = args.detect { |role| user.has_role?(role) } end if has_any begin capture( &block ) rescue NoMethodError yield( :block ) end end end |