Class: RolePlays::Mixin::Role
- Inherits:
-
BaseStruct
- Object
- Dry::Struct
- BaseStruct
- RolePlays::Mixin::Role
- Defined in:
- lib/role_plays/mixin.rb
Overview
What one role may do: the actions it declares, the attributes it may submit per label and the
scopes it may read per label. Built by RoleBuilder from a role block, or by hand to share a
role between policies.
Instance Method Summary collapse
- #action_for(name) ⇒ Object
-
#merge(other) ⇒ Object
Later declarations win, so a policy can extend or override a role it was given.
- #permitted_attributes_for(label) ⇒ Object
- #scope_for(label) ⇒ Object
Instance Method Details
#action_for(name) ⇒ Object
108 109 110 |
# File 'lib/role_plays/mixin.rb', line 108 def action_for(name) actions[name] end |
#merge(other) ⇒ Object
Later declarations win, so a policy can extend or override a role it was given
121 122 123 124 125 |
# File 'lib/role_plays/mixin.rb', line 121 def merge(other) new(actions: actions.merge(other.actions), permitted_attributes: permitted_attributes.merge(other.permitted_attributes), scopes: scopes.merge(other.scopes)) end |
#permitted_attributes_for(label) ⇒ Object
112 113 114 |
# File 'lib/role_plays/mixin.rb', line 112 def permitted_attributes_for(label) permitted_attributes[label] end |
#scope_for(label) ⇒ Object
116 117 118 |
# File 'lib/role_plays/mixin.rb', line 116 def scope_for(label) scopes[label] end |