Class: AbstractResourcePolicy
- Inherits:
-
Object
- Object
- AbstractResourcePolicy
- Defined in:
- app/policies/abstract_resource_policy.rb
Defined Under Namespace
Classes: Scope
Instance Attribute Summary collapse
-
#current_user ⇒ Object
readonly
Returns the value of attribute current_user.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
Instance Method Summary collapse
- #activate? ⇒ Boolean
- #attach? ⇒ Boolean
- #create? ⇒ Boolean
- #deactivate? ⇒ Boolean
- #defer? ⇒ Boolean
- #delete? ⇒ Boolean
- #destroy? ⇒ Boolean
- #detach? ⇒ Boolean
- #edit? ⇒ Boolean
- #index? ⇒ Boolean
-
#initialize(current_user, model) ⇒ AbstractResourcePolicy
constructor
A new instance of AbstractResourcePolicy.
- #new? ⇒ Boolean
- #prefer? ⇒ Boolean
- #show? ⇒ Boolean
- #update? ⇒ Boolean
Constructor Details
#initialize(current_user, model) ⇒ AbstractResourcePolicy
Returns a new instance of AbstractResourcePolicy.
18 19 20 21 |
# File 'app/policies/abstract_resource_policy.rb', line 18 def initialize(current_user, model) @current_user = current_user @model = model end |
Instance Attribute Details
#current_user ⇒ Object (readonly)
Returns the value of attribute current_user.
16 17 18 |
# File 'app/policies/abstract_resource_policy.rb', line 16 def current_user @current_user end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
16 17 18 |
# File 'app/policies/abstract_resource_policy.rb', line 16 def model @model end |
Instance Method Details
#activate? ⇒ Boolean
79 80 81 |
# File 'app/policies/abstract_resource_policy.rb', line 79 def activate? true end |
#attach? ⇒ Boolean
63 64 65 |
# File 'app/policies/abstract_resource_policy.rb', line 63 def attach? true end |
#create? ⇒ Boolean
43 44 45 46 |
# File 'app/policies/abstract_resource_policy.rb', line 43 def create? # @current_user.admin? true end |
#deactivate? ⇒ Boolean
83 84 85 |
# File 'app/policies/abstract_resource_policy.rb', line 83 def deactivate? true end |
#defer? ⇒ Boolean
75 76 77 |
# File 'app/policies/abstract_resource_policy.rb', line 75 def defer? true end |
#delete? ⇒ Boolean
59 60 61 |
# File 'app/policies/abstract_resource_policy.rb', line 59 def delete? true end |
#destroy? ⇒ Boolean
53 54 55 56 57 |
# File 'app/policies/abstract_resource_policy.rb', line 53 def destroy? # return false if @current_user == @user # @current_user.admin? true end |
#detach? ⇒ Boolean
67 68 69 |
# File 'app/policies/abstract_resource_policy.rb', line 67 def detach? true end |
#edit? ⇒ Boolean
33 34 35 36 |
# File 'app/policies/abstract_resource_policy.rb', line 33 def edit? # @current_user.admin? true end |
#index? ⇒ Boolean
23 24 25 26 |
# File 'app/policies/abstract_resource_policy.rb', line 23 def index? # @current_user.admin? true end |
#new? ⇒ Boolean
28 29 30 31 |
# File 'app/policies/abstract_resource_policy.rb', line 28 def new? # @current_user.admin? true end |
#prefer? ⇒ Boolean
71 72 73 |
# File 'app/policies/abstract_resource_policy.rb', line 71 def prefer? true end |
#show? ⇒ Boolean
38 39 40 41 |
# File 'app/policies/abstract_resource_policy.rb', line 38 def show? # @current_user.admin? or @current_user == @user true end |
#update? ⇒ Boolean
48 49 50 51 |
# File 'app/policies/abstract_resource_policy.rb', line 48 def update? # @current_user.admin? true end |