Class: Toni::Builder::RoleBuilder
- Inherits:
-
Object
- Object
- Toni::Builder::RoleBuilder
- Defined in:
- lib/toni/builder.rb
Instance Attribute Summary collapse
-
#role ⇒ Object
readonly
Returns the value of attribute role.
Instance Method Summary collapse
-
#has_permission_on(resource_name, options = {}, &block) ⇒ Object
Add permissions to specific role.
-
#includes(role_symbol) ⇒ Object
Add an ancestor to the current role.
-
#initialize(role_symbol, &block) ⇒ RoleBuilder
constructor
A new instance of RoleBuilder.
Constructor Details
#initialize(role_symbol, &block) ⇒ RoleBuilder
Returns a new instance of RoleBuilder.
24 25 26 27 28 29 |
# File 'lib/toni/builder.rb', line 24 def initialize(role_symbol, &block) @role = Role.new(role_symbol) if block_given? instance_eval &block end end |
Instance Attribute Details
#role ⇒ Object (readonly)
Returns the value of attribute role.
22 23 24 |
# File 'lib/toni/builder.rb', line 22 def role @role end |
Instance Method Details
#has_permission_on(resource_name, options = {}, &block) ⇒ Object
Add permissions to specific role
37 38 39 40 |
# File 'lib/toni/builder.rb', line 37 def (resource_name, ={}, &block) builder = PermissionBuilder.new(resource_name, , &block) @role.(builder.) end |
#includes(role_symbol) ⇒ Object
Add an ancestor to the current role
32 33 34 |
# File 'lib/toni/builder.rb', line 32 def includes(role_symbol) @role.add_ancestor(role_symbol) end |