Class: Rollenspiel::RoleProvider::RoleStructure
- Inherits:
-
Object
- Object
- Rollenspiel::RoleProvider::RoleStructure
- Defined in:
- app/models/rollenspiel/role_provider/role_structure.rb
Instance Method Summary collapse
-
#initialize ⇒ RoleStructure
constructor
A new instance of RoleStructure.
- #layout ⇒ Object
- #roles(*roles_with_options) ⇒ Object (also: #role)
Constructor Details
#initialize ⇒ RoleStructure
Returns a new instance of RoleStructure.
4 5 6 7 8 |
# File 'app/models/rollenspiel/role_provider/role_structure.rb', line 4 def initialize @roles = [] @inheritances = {} @callbacks = {on_grant: {}} end |
Instance Method Details
#layout ⇒ Object
31 32 33 34 35 36 37 |
# File 'app/models/rollenspiel/role_provider/role_structure.rb', line 31 def layout { inheritances: @inheritances, roles: @roles, callbacks: @callbacks } end |
#roles(*roles_with_options) ⇒ Object Also known as: role
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/models/rollenspiel/role_provider/role_structure.rb', line 10 def roles * roles = .dup = roles.last.kind_of?(Hash) ? roles.pop : {} @roles << roles @roles << [:inherits] if [:inherits] @roles.flatten! @roles.compact! @roles.uniq! if inherits = [:inherits] roles.each do |role| @inheritances[role] = inherits end end if on_grant = [:on_grant] roles.each do |role| @callbacks[:on_grant][role] = RoleCallback.new(on_grant) end end end |