Class: Aclatraz::ACL::Action
- Inherits:
-
Object
- Object
- Aclatraz::ACL::Action
- Defined in:
- lib/aclatraz/acl.rb
Instance Attribute Summary collapse
-
#permissions ⇒ Object
readonly
All permissions defined in this action.
Instance Method Summary collapse
-
#all ⇒ Object
Syntactic sugar for aliasing all permissions.
-
#allow(permission) ⇒ Object
Add permission for objects which have given role.
-
#clone(parent) ⇒ Object
:nodoc:.
-
#deny(permission) ⇒ Object
Add permission for objects which don’t have given role.
-
#initialize(parent, &block) ⇒ Action
constructor
A new instance of Action.
-
#on(*args, &block) ⇒ Object
See
Aclatraz::ACL#on
.
Constructor Details
#initialize(parent, &block) ⇒ Action
Returns a new instance of Action.
7 8 9 10 11 |
# File 'lib/aclatraz/acl.rb', line 7 def initialize(parent, &block) @parent = parent @permissions = Dictionary.new {|h,k| h[k] = false}.merge(parent.) instance_eval(&block) if block_given? end |
Instance Attribute Details
#permissions ⇒ Object (readonly)
All permissions defined in this action.
5 6 7 |
# File 'lib/aclatraz/acl.rb', line 5 def @permissions end |
Instance Method Details
#all ⇒ Object
Syntactic sugar for aliasing all permissions.
Examples
allow all
deny all
47 48 49 |
# File 'lib/aclatraz/acl.rb', line 47 def all true end |
#allow(permission) ⇒ Object
Add permission for objects which have given role.
Examples
allow :admin
allow :owner_of => "object"
allow :owner_of => :object
allow :owner_of => object
allow :manager_of => ClassName
allow all
23 24 25 |
# File 'lib/aclatraz/acl.rb', line 23 def allow() @permissions[] = true end |
#clone(parent) ⇒ Object
:nodoc:
56 57 58 |
# File 'lib/aclatraz/acl.rb', line 56 def clone(parent) # :nodoc: self.class.new(parent) end |
#deny(permission) ⇒ Object
Add permission for objects which don’t have given role.
Examples
deny :admin
deny :owner_of => "object"
deny :owner_of => :object
deny :owner_of => object
deny :manager_of => ClassName
deny all
37 38 39 |
# File 'lib/aclatraz/acl.rb', line 37 def deny() @permissions[] = false end |
#on(*args, &block) ⇒ Object
See Aclatraz::ACL#on
.
52 53 54 |
# File 'lib/aclatraz/acl.rb', line 52 def on(*args, &block) @parent.on(*args, &block) end |