Class: YaAcl::Builder
- Inherits:
-
Object
show all
- Defined in:
- lib/ya_acl/builder.rb
Defined Under Namespace
Classes: PrivilegeAssertProxy, PrivilegeProxy
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(block) ⇒ Builder
Returns a new instance of Builder.
10
11
12
13
|
# File 'lib/ya_acl/builder.rb', line 10
def initialize block
self.acl = Acl.new
instance_eval &block
end
|
Instance Attribute Details
#acl ⇒ Object
Returns the value of attribute acl.
3
4
5
|
# File 'lib/ya_acl/builder.rb', line 3
def acl
@acl
end
|
Class Method Details
.build(&block) ⇒ Object
5
6
7
8
|
# File 'lib/ya_acl/builder.rb', line 5
def self.build &block
builder = new block
Acl.instance = builder.acl
end
|
Instance Method Details
#assert(name, param_names, &block) ⇒ Object
27
28
29
|
# File 'lib/ya_acl/builder.rb', line 27
def assert(name, param_names, &block)
acl.add_assert Assert.new(name, param_names, &block)
end
|
#asserts(&block) ⇒ Object
19
20
21
|
# File 'lib/ya_acl/builder.rb', line 19
def asserts(&block)
instance_eval &block
end
|
#resource(name, allow_roles = [], &block) ⇒ Object
36
37
38
39
40
41
42
|
# File 'lib/ya_acl/builder.rb', line 36
def resource(name, allow_roles = [], &block)
raise ArgumentError, 'Options "allow_roles" must be Array' unless allow_roles.is_a? Array
resource_allow_roles = allow_roles << @global_allow_role
resource = Resource.new(name)
acl.add_resource resource
PrivilegeProxy.new(resource.name, resource_allow_roles, acl, block)
end
|
#resources(allow, &block) ⇒ Object
31
32
33
34
|
# File 'lib/ya_acl/builder.rb', line 31
def resources(allow, &block)
@global_allow_role = allow
instance_eval &block
end
|
#role(name, options = {}) ⇒ Object
23
24
25
|
# File 'lib/ya_acl/builder.rb', line 23
def role(name, options = {})
acl.add_role Role.new(name, options)
end
|
#roles(&block) ⇒ Object
15
16
17
|
# File 'lib/ya_acl/builder.rb', line 15
def roles(&block)
instance_eval &block
end
|