Module: ActionPolicy::Policy::Reasons::InstanceMethods
- Defined in:
- lib/action_policy/policy/reasons.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#allowed_to?(rule, record = :__undef__, **options) ⇒ Boolean
rubocop: disable Metrics/MethodLength.
- #apply(rule) ⇒ Object
Instance Method Details
#allowed_to?(rule, record = :__undef__, **options) ⇒ Boolean
rubocop: disable Metrics/MethodLength
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/action_policy/policy/reasons.rb', line 89 def allowed_to?(rule, record = :__undef__, **) policy = nil succeed = if record == :__undef__ policy = self with_clean_reasons { apply(rule) } else policy = policy_for(record: record, **) policy.apply(rule) end reasons.add(policy, rule) if reasons && !succeed succeed end |
#apply(rule) ⇒ Object
83 84 85 86 |
# File 'lib/action_policy/policy/reasons.rb', line 83 def apply(rule) @reasons = FailureReasons.new super end |