Class: CrewdPolicies::BasePolicy
- Inherits:
-
Object
- Object
- CrewdPolicies::BasePolicy
- Includes:
- Policy
- Defined in:
- lib/crewd_policies/base_policy.rb
Overview
optional
Defined Under Namespace
Classes: Scope
Instance Attribute Summary collapse
-
#identity ⇒ Object
readonly
Returns the value of attribute identity.
-
#record ⇒ Object
readonly
Returns the value of attribute record.
Instance Method Summary collapse
-
#initialize(identity, record) ⇒ BasePolicy
constructor
A new instance of BasePolicy.
- #model_class ⇒ Object
- #scope ⇒ Object
Methods included from Policy
#all_attributes, #allowed?, #allowed_associations, #allowed_attributes, #allowed_fields, #create?, #destroy?, #edit?, #forbidden!, #index?, #new?, #permitted_attributes, #read?, #record_class, #show?, #unauthorized!, #update?, #write?
Constructor Details
#initialize(identity, record) ⇒ BasePolicy
Returns a new instance of BasePolicy.
12 13 14 15 |
# File 'lib/crewd_policies/base_policy.rb', line 12 def initialize(identity, record) @identity = identity @record = record end |
Instance Attribute Details
#identity ⇒ Object (readonly)
Returns the value of attribute identity.
10 11 12 |
# File 'lib/crewd_policies/base_policy.rb', line 10 def identity @identity end |
#record ⇒ Object (readonly)
Returns the value of attribute record.
10 11 12 |
# File 'lib/crewd_policies/base_policy.rb', line 10 def record @record end |
Instance Method Details
#model_class ⇒ Object
17 18 19 |
# File 'lib/crewd_policies/base_policy.rb', line 17 def model_class @policy_class ||= self.class.name.sub(/Policy$/,'').safe_constantize # record ? record.class end |
#scope ⇒ Object
21 22 23 |
# File 'lib/crewd_policies/base_policy.rb', line 21 def scope Pundit.policy_scope!(identity, model_class) end |