Class: Role::OptionBuilder
- Inherits:
-
Object
- Object
- Role::OptionBuilder
- Defined in:
- lib/pundit_roles/policy/role/option_builder.rb
Overview
Helper class, which handles building of a role’s #permissions_hash.
Instance Attribute Summary collapse
-
#policy ⇒ Object
readonly
Returns the value of attribute policy.
Instance Method Summary collapse
-
#initialize(policy, attr_opts, assoc_opts, scope) ⇒ OptionBuilder
constructor
A new instance of OptionBuilder.
-
#permitted ⇒ Object
Returns a refined hash of attributes and associations the current_user has access to.
Constructor Details
#initialize(policy, attr_opts, assoc_opts, scope) ⇒ OptionBuilder
Returns a new instance of OptionBuilder.
13 14 15 16 17 18 19 |
# File 'lib/pundit_roles/policy/role/option_builder.rb', line 13 def initialize(policy, attr_opts, assoc_opts, scope) @policy = policy @attr_opts = attr_opts @assoc_opts = assoc_opts @scope = scope freeze end |
Instance Attribute Details
#policy ⇒ Object (readonly)
Returns the value of attribute policy.
11 12 13 |
# File 'lib/pundit_roles/policy/role/option_builder.rb', line 11 def policy @policy end |
Instance Method Details
#permitted ⇒ Object
Returns a refined hash of attributes and associations the current_user has access to
22 23 24 25 26 27 |
# File 'lib/pundit_roles/policy/role/option_builder.rb', line 22 def permitted return { attributes: (@attr_opts, 'attributes'), associations: (@assoc_opts, 'associations') } end |