Module: Eaco::Actor
- Defined in:
- lib/eaco/actor.rb
Overview
An Actor is an entity whose access to Resources is discretionary, depending on the Role this actor has in the ACL.
The role of this Actor is calculated from the Designator that the actor instance has, and the ACL instance attached to the Resource.
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
-
#can?(action, resource) ⇒ Boolean
Checks wether the given Resource allows this Actor to perform the given action.
-
#cannot?(*args) ⇒ Boolean
Opposite of #can?.
-
#designators ⇒ Set
The designators granted to this Actor.
-
#is_admin? ⇒ Boolean
Checks whether this Actor fulfills the admin logic.
Instance Method Details
#can?(action, resource) ⇒ Boolean
Checks wether the given Resource allows this Actor to perform the given action.
82 83 84 |
# File 'lib/eaco/actor.rb', line 82 def can?(action, resource) resource.allows?(action, self) end |
#cannot?(*args) ⇒ Boolean
Opposite of #can?.
92 93 94 |
# File 'lib/eaco/actor.rb', line 92 def cannot?(*args) !can?(*args) end |
#designators ⇒ Set
Returns the designators granted to this Actor.
51 52 53 54 55 56 57 |
# File 'lib/eaco/actor.rb', line 51 def designators Set.new.tap do |ret| self.class.designators.each do |_, designator| ret.merge designator.harvest(self) end end end |
#is_admin? ⇒ Boolean
Checks whether this Actor fulfills the admin logic.
This logic is called by Resource Adapters’ accessible_by, that returns the full collection, and by Resource#allows?, that bypassess access checks always returning true.
68 69 70 71 72 |
# File 'lib/eaco/actor.rb', line 68 def is_admin? return unless self.class.admin_logic instance_exec(self, &self.class.admin_logic) end |