Class: Recurso::ResourcePolicy
- Inherits:
-
BasePolicy
- Object
- Struct
- BasePolicy
- Recurso::ResourcePolicy
- Defined in:
- lib/recurso/policies/resource_policy.rb
Instance Attribute Summary
Attributes inherited from BasePolicy
Instance Method Summary collapse
- #method_missing(method) ⇒ Object
- #resources_with_permission(relation_name, action: :view, all_columns: true, include_actions: [:modify, :administer]) ⇒ Object
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method) ⇒ Object
3 4 5 6 7 8 |
# File 'lib/recurso/policies/resource_policy.rb', line 3 def method_missing(method) action = method.to_s.sub('?', '').to_sym super unless Recurso::Config.instance.levels_for_action.keys.include?(action) Recurso::Queries::Single.new(identity, resource, action). end |
Instance Method Details
#resources_with_permission(relation_name, action: :view, all_columns: true, include_actions: [:modify, :administer]) ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/recurso/policies/resource_policy.rb', line 10 def (relation_name, action: :view, all_columns: true, include_actions: [:modify, :administer]) Recurso::Queries::Relation.new( identity, resource, relation_name, all_columns: all_columns, action: action, include_actions: include_actions, ).resources end |