Class: ApiPresenter::Resolvers::PoliciesResolver
- Defined in:
- lib/api_presenter/resolvers/policies_resolver.rb
Instance Attribute Summary collapse
-
#presenter ⇒ Object
readonly
Returns the value of attribute presenter.
-
#resolved_policies ⇒ Object
readonly
Returns the value of attribute resolved_policies.
Instance Method Summary collapse
-
#call ⇒ PolicyPresenter::Base
Resolves policies and combines them into an id-based hash.
-
#initialize(presenter) ⇒ PoliciesResolver
constructor
Optimally resolves designated policies for current_user and supplied records.
Constructor Details
#initialize(presenter) ⇒ PoliciesResolver
Optimally resolves designated policies for current_user and supplied records.
Use where it is desirable for an API response to include permissions (policy) metadata so that a client can correctly present resource actions.
Initialize and preload policy associations for the given relation
17 18 19 20 |
# File 'lib/api_presenter/resolvers/policies_resolver.rb', line 17 def initialize(presenter) super(presenter) preload if relation.is_a?(ActiveRecord::Relation) && policy_associations.present? end |
Instance Attribute Details
#presenter ⇒ Object (readonly)
Returns the value of attribute presenter.
5 6 7 |
# File 'lib/api_presenter/resolvers/policies_resolver.rb', line 5 def presenter @presenter end |
#resolved_policies ⇒ Object (readonly)
Returns the value of attribute resolved_policies.
5 6 7 |
# File 'lib/api_presenter/resolvers/policies_resolver.rb', line 5 def resolved_policies @resolved_policies end |
Instance Method Details
#call ⇒ PolicyPresenter::Base
Resolves policies and combines them into an id-based hash
26 27 28 29 |
# File 'lib/api_presenter/resolvers/policies_resolver.rb', line 26 def call resolve_policies self end |