Class: Vert::Authorization::DynamicPolicy
- Inherits:
-
Object
- Object
- Vert::Authorization::DynamicPolicy
- Defined in:
- lib/vert/authorization/dynamic_policy.rb
Defined Under Namespace
Classes: Scope
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#record ⇒ Object
readonly
Returns the value of attribute record.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
- #approve? ⇒ Boolean
- #cancel? ⇒ Boolean
- #create? ⇒ Boolean
- #destroy? ⇒ Boolean
- #edit? ⇒ Boolean
- #export? ⇒ Boolean
- #import? ⇒ Boolean
- #index? ⇒ Boolean
-
#initialize(user, record, context = {}) ⇒ DynamicPolicy
constructor
A new instance of DynamicPolicy.
- #new? ⇒ Boolean
- #print? ⇒ Boolean
- #reject? ⇒ Boolean
- #show? ⇒ Boolean
- #update? ⇒ Boolean
Constructor Details
#initialize(user, record, context = {}) ⇒ DynamicPolicy
Returns a new instance of DynamicPolicy.
8 9 10 11 12 |
# File 'lib/vert/authorization/dynamic_policy.rb', line 8 def initialize(user, record, context = {}) @user = user @record = record @context = default_context.merge(context) end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
6 7 8 |
# File 'lib/vert/authorization/dynamic_policy.rb', line 6 def context @context end |
#record ⇒ Object (readonly)
Returns the value of attribute record.
6 7 8 |
# File 'lib/vert/authorization/dynamic_policy.rb', line 6 def record @record end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
6 7 8 |
# File 'lib/vert/authorization/dynamic_policy.rb', line 6 def user @user end |
Instance Method Details
#approve? ⇒ Boolean
50 51 52 |
# File 'lib/vert/authorization/dynamic_policy.rb', line 50 def approve? ("#{resource_name}.approve") end |
#cancel? ⇒ Boolean
58 59 60 |
# File 'lib/vert/authorization/dynamic_policy.rb', line 58 def cancel? ("#{resource_name}.cancel") end |
#create? ⇒ Boolean
22 23 24 |
# File 'lib/vert/authorization/dynamic_policy.rb', line 22 def create? ("#{resource_name}.create") end |
#destroy? ⇒ Boolean
38 39 40 |
# File 'lib/vert/authorization/dynamic_policy.rb', line 38 def destroy? ("#{resource_name}.delete") end |
#edit? ⇒ Boolean
34 35 36 |
# File 'lib/vert/authorization/dynamic_policy.rb', line 34 def edit? update? end |
#export? ⇒ Boolean
42 43 44 |
# File 'lib/vert/authorization/dynamic_policy.rb', line 42 def export? ("#{resource_name}.export") end |
#import? ⇒ Boolean
46 47 48 |
# File 'lib/vert/authorization/dynamic_policy.rb', line 46 def import? ("#{resource_name}.import") end |
#index? ⇒ Boolean
14 15 16 |
# File 'lib/vert/authorization/dynamic_policy.rb', line 14 def index? ("#{resource_name}.list") end |
#new? ⇒ Boolean
26 27 28 |
# File 'lib/vert/authorization/dynamic_policy.rb', line 26 def new? create? end |
#print? ⇒ Boolean
62 63 64 |
# File 'lib/vert/authorization/dynamic_policy.rb', line 62 def print? ("#{resource_name}.print") end |
#reject? ⇒ Boolean
54 55 56 |
# File 'lib/vert/authorization/dynamic_policy.rb', line 54 def reject? ("#{resource_name}.reject") end |
#show? ⇒ Boolean
18 19 20 |
# File 'lib/vert/authorization/dynamic_policy.rb', line 18 def show? ("#{resource_name}.read") end |
#update? ⇒ Boolean
30 31 32 |
# File 'lib/vert/authorization/dynamic_policy.rb', line 30 def update? ("#{resource_name}.update") end |