Class: Toni::Builder::RoleBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/toni/builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#roleObject (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 has_permission_on(resource_name, options={}, &block)
  builder = PermissionBuilder.new(resource_name, options, &block)
  @role.add_permission(builder.permission)
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