Class: ResourcePolicy::Policy::ActionsPolicy::ActionsPolicyModel

Inherits:
Object
  • Object
show all
Defined in:
lib/resource_policy/policy/actions_policy/actions_policy_model.rb

Overview

Class which isolates methods defined via actions_policy config

Instance Method Summary collapse

Constructor Details

#initialize(policy) ⇒ ActionsPolicyModel

Returns a new instance of ActionsPolicyModel.



10
11
12
13
# File 'lib/resource_policy/policy/actions_policy/actions_policy_model.rb', line 10

def initialize(policy)
  @policy = policy
  @policy_item_by_name ||= {}
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name) ⇒ Object



15
16
17
18
19
# File 'lib/resource_policy/policy/actions_policy/actions_policy_model.rb', line 15

def method_missing(method_name)
  return super unless config.actions.key?(method_name.to_sym)

  policy_item(method_name.to_sym)
end

Instance Method Details

#respond_to_missing?(method_name, *args) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/resource_policy/policy/actions_policy/actions_policy_model.rb', line 21

def respond_to_missing?(method_name, *args)
  config.actions.key?(method_name.to_sym) || super
end