Module: StoneWall::UserExtensions
- Defined in:
- lib/stonewall/user_extensions.rb
Instance Method Summary collapse
-
#may_send?(object, method) ⇒ Boolean
I like Aegis so much, I stole their idea for this part of the gem.
-
#stonewall_role_info ⇒ Object
This is the ugliest method in the whole gem.
Instance Method Details
#may_send?(object, method) ⇒ Boolean
I like Aegis so much, I stole their idea for this part of the gem. I hope you don't mind guys, but I really need an ACL that triggers off of object state!
32 33 34 |
# File 'lib/stonewall/user_extensions.rb', line 32 def may_send?(object, method) object.class.stonewall.allowed?(object, self, method) end |
#stonewall_role_info ⇒ Object
This is the ugliest method in the whole gem. You have a lot of freedom in how you implement your role system, and I have to adapt to that. You can have:
- role as a string on your class
- role as a singular has_one or belongs_to relationship
- your user can has_many :roles, and they can be any object you want. The only thing we require is that, if your role is a separate object, it responds to a 'name' method with a string or a symbol that matches the symbol you use when defining the permissions in your dsl.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/stonewall/user_extensions.rb', line 14 def stonewall_role_info return @role_symbols if @role_symbols @role_symbols = Array.new if self.respond_to?(:role) @role_symbols << StoneWall::Helpers.symbolize_role(role) end if self.respond_to?(:roles) roles.each do |role| @role_symbols << StoneWall::Helpers.symbolize_role(role) end end @role_symbols end |