Class: Accessly::Permission::Grant
- Defined in:
- lib/accessly/permission/grant.rb
Instance Method Summary collapse
-
#grant!(action_id, object_type, object_id = nil) ⇒ nil
Grant a permission to an actor.
-
#initialize(actor) ⇒ Grant
constructor
Create an instance of Accessly::Permission::Grant Pass in an ActiveRecord::Base for actor.
Methods inherited from Base
Constructor Details
#initialize(actor) ⇒ Grant
Create an instance of Accessly::Permission::Grant Pass in an ActiveRecord::Base for actor
9 10 11 12 13 14 15 16 17 |
# File 'lib/accessly/permission/grant.rb', line 9 def initialize(actor) super(actor) @actor = case actor when ActiveRecord::Base actor else raise Accessly::GrantError.new("Actor is not an ActiveRecord::Base object") end end |
Instance Method Details
#grant!(action_id, object_type) ⇒ nil #grant!(action_id, object_type, object_id) ⇒ nil
Grant a permission to an actor.
53 54 55 56 57 58 59 |
# File 'lib/accessly/permission/grant.rb', line 53 def grant!(action_id, object_type, object_id = nil) if object_id.nil? general_action_grant(action_id, object_type) else object_action_grant(action_id, object_type, object_id) end end |