Exception: ActionPolicy::UnknownRule

Inherits:
Error
  • Object
show all
Includes:
SuggestMessage
Defined in:
lib/action_policy/policy/core.rb

Overview

Raised when ‘resolve_rule` failed to find an approriate policy rule method for the activity

Direct Known Subclasses

NonPredicateRule

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from SuggestMessage

#suggest

Constructor Details

#initialize(policy, rule) ⇒ UnknownRule

Returns a new instance of UnknownRule.



23
24
25
26
27
28
# File 'lib/action_policy/policy/core.rb', line 23

def initialize(policy, rule)
  @policy = policy.class
  @rule = rule
  @message = "Couldn't find rule '#{@rule}' for #{@policy}" \
    "#{suggest(@rule, @policy.instance_methods - Object.instance_methods)}"
end

Instance Attribute Details

#messageObject (readonly)

Returns the value of attribute message.



21
22
23
# File 'lib/action_policy/policy/core.rb', line 21

def message
  @message
end

#policyObject (readonly)

Returns the value of attribute policy.



21
22
23
# File 'lib/action_policy/policy/core.rb', line 21

def policy
  @policy
end

#ruleObject (readonly)

Returns the value of attribute rule.



21
22
23
# File 'lib/action_policy/policy/core.rb', line 21

def rule
  @rule
end