Class: ActiveRecordApi::Rest::ApplicationPolicy
- Inherits:
-
Object
- Object
- ActiveRecordApi::Rest::ApplicationPolicy
- Defined in:
- lib/active_record_api/rest/application_policy.rb
Defined Under Namespace
Classes: Scope
Constant Summary collapse
- READ =
'read'.freeze
- MANAGE =
'manage'.freeze
Instance Attribute Summary collapse
-
#model_class ⇒ Object
readonly
Returns the value of attribute model_class.
-
#session ⇒ Object
readonly
Returns the value of attribute session.
Instance Method Summary collapse
- #create? ⇒ Boolean
- #destroy? ⇒ Boolean
- #index? ⇒ Boolean
-
#initialize(session, model_class) ⇒ ApplicationPolicy
constructor
A new instance of ApplicationPolicy.
- #show? ⇒ Boolean
- #update? ⇒ Boolean
Constructor Details
#initialize(session, model_class) ⇒ ApplicationPolicy
Returns a new instance of ApplicationPolicy.
23 24 25 26 |
# File 'lib/active_record_api/rest/application_policy.rb', line 23 def initialize(session, model_class) @session = session @model_class = model_class end |
Instance Attribute Details
#model_class ⇒ Object (readonly)
Returns the value of attribute model_class.
18 19 20 |
# File 'lib/active_record_api/rest/application_policy.rb', line 18 def model_class @model_class end |
#session ⇒ Object (readonly)
Returns the value of attribute session.
17 18 19 |
# File 'lib/active_record_api/rest/application_policy.rb', line 17 def session @session end |
Instance Method Details
#create? ⇒ Boolean
36 37 38 |
# File 'lib/active_record_api/rest/application_policy.rb', line 36 def create? can?(MANAGE) end |
#destroy? ⇒ Boolean
44 45 46 |
# File 'lib/active_record_api/rest/application_policy.rb', line 44 def destroy? can?(MANAGE) end |
#index? ⇒ Boolean
28 29 30 |
# File 'lib/active_record_api/rest/application_policy.rb', line 28 def index? can?(READ) end |
#show? ⇒ Boolean
32 33 34 |
# File 'lib/active_record_api/rest/application_policy.rb', line 32 def show? can?(READ) end |
#update? ⇒ Boolean
40 41 42 |
# File 'lib/active_record_api/rest/application_policy.rb', line 40 def update? can?(MANAGE) end |