Module: ActionPolicy::Graphiti::PolicyNameInferrer

Defined in:
lib/action_policy/graphiti/policy_name_inferrer.rb

Overview

Infer policy names for Graphiti resources

Class Method Summary collapse

Class Method Details

.infer(resource) ⇒ Object



9
10
11
12
13
# File 'lib/action_policy/graphiti/policy_name_inferrer.rb', line 9

def self.infer(resource)
  model_name = ResourceAnalyzer.model_name(resource)

  "#{model_name}Policy" if model_name
end

.infer_polymorphic(resource) ⇒ Object



15
16
17
18
19
# File 'lib/action_policy/graphiti/policy_name_inferrer.rb', line 15

def self.infer_polymorphic(resource)
  base_model_name = ResourceAnalyzer.base_model_name(resource)

  "#{base_model_name}Policy" if base_model_name
end