Module: ActionPolicy::Graphiti::ResourceValidator
- Defined in:
- lib/action_policy/graphiti/resource_validator.rb
Overview
Validate Graphiti resources Provides a few helpers mostly used in policy class lookups
Class Method Summary collapse
Class Method Details
.graphiti_resource?(resource) ⇒ Boolean
8 9 10 11 12 13 14 15 |
# File 'lib/action_policy/graphiti/resource_validator.rb', line 8 def self.graphiti_resource?(resource) resource_class = resource.is_a?(Class) ? resource : resource.class return unless resource_class.name.end_with?("Resource") && resource_class.ancestors.include?(::Graphiti::Resource) true end |
.polymorphic_graphiti_resource?(resource) ⇒ Boolean
17 18 19 20 21 22 23 24 25 |
# File 'lib/action_policy/graphiti/resource_validator.rb', line 17 def self.polymorphic_graphiti_resource?(resource) resource_class = resource.is_a?(Class) ? resource : resource.class return unless resource_class.name.end_with?("Resource") && resource_class.ancestors.include?(::Graphiti::Resource::Polymorphism) && resource_class.ancestors.include?(::Graphiti::Resource) true end |