Class: ResourcePolicy::Policy::ActionsPolicy::ActionPolicy
- Inherits:
-
Object
- Object
- ResourcePolicy::Policy::ActionsPolicy::ActionPolicy
- Defined in:
- lib/resource_policy/policy/actions_policy/action_policy.rb
Overview
Contains information about single action
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #allowed? ⇒ Boolean
-
#initialize(name, policy:) ⇒ ActionPolicy
constructor
A new instance of ActionPolicy.
Constructor Details
#initialize(name, policy:) ⇒ ActionPolicy
Returns a new instance of ActionPolicy.
10 11 12 13 |
# File 'lib/resource_policy/policy/actions_policy/action_policy.rb', line 10 def initialize(name, policy:) @name = name.to_sym @policy = policy end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/resource_policy/policy/actions_policy/action_policy.rb', line 8 def name @name end |
Instance Method Details
#allowed? ⇒ Boolean
15 16 17 18 19 20 |
# File 'lib/resource_policy/policy/actions_policy/action_policy.rb', line 15 def allowed? return @allowed if defined?(@allowed) conditions = policy_config.action(name).conditions @allowed = conditions.all? { |condition| policy.send(condition) } end |