Class: ActionAuthorization::BasePolicy
- Inherits:
-
Object
- Object
- ActionAuthorization::BasePolicy
- Defined in:
- lib/action_authorization/base_policy.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#object ⇒ Object
Returns the value of attribute object.
-
#user ⇒ Object
Returns the value of attribute user.
Class Method Summary collapse
-
.inherited(klass) ⇒ Object
create alias to object from subclass name.
- .type ⇒ Object
- .type_class ⇒ Object
Instance Method Summary collapse
- #create? ⇒ Boolean
- #destroy? ⇒ Boolean
- #edit? ⇒ Boolean
- #index? ⇒ Boolean
-
#initialize(user, object = nil) ⇒ BasePolicy
constructor
A new instance of BasePolicy.
- #new? ⇒ Boolean
- #show? ⇒ Boolean
- #update? ⇒ Boolean
Constructor Details
#initialize(user, object = nil) ⇒ BasePolicy
Returns a new instance of BasePolicy.
19 20 21 22 |
# File 'lib/action_authorization/base_policy.rb', line 19 def initialize(user, object = nil) self.user = user self.object = object end |
Instance Attribute Details
#object ⇒ Object
Returns the value of attribute object.
5 6 7 |
# File 'lib/action_authorization/base_policy.rb', line 5 def object @object end |
#user ⇒ Object
Returns the value of attribute user.
5 6 7 |
# File 'lib/action_authorization/base_policy.rb', line 5 def user @user end |
Class Method Details
.inherited(klass) ⇒ Object
create alias to object from subclass name
25 26 27 28 |
# File 'lib/action_authorization/base_policy.rb', line 25 def self.inherited(klass) super klass.send(:alias_method, klass.type.underscore, :object) end |
.type ⇒ Object
7 8 9 |
# File 'lib/action_authorization/base_policy.rb', line 7 def self.type name.delete_suffix("Policy") end |
.type_class ⇒ Object
11 12 13 14 15 |
# File 'lib/action_authorization/base_policy.rb', line 11 def self.type_class type.constantize rescue NameError NilClass end |
Instance Method Details
#create? ⇒ Boolean
42 43 44 |
# File 'lib/action_authorization/base_policy.rb', line 42 def create? end |
#destroy? ⇒ Boolean
54 55 56 |
# File 'lib/action_authorization/base_policy.rb', line 54 def destroy? create? end |
#edit? ⇒ Boolean
46 47 48 |
# File 'lib/action_authorization/base_policy.rb', line 46 def edit? update? end |
#index? ⇒ Boolean
30 31 32 |
# File 'lib/action_authorization/base_policy.rb', line 30 def index? end |
#new? ⇒ Boolean
38 39 40 |
# File 'lib/action_authorization/base_policy.rb', line 38 def new? create? end |
#show? ⇒ Boolean
34 35 36 |
# File 'lib/action_authorization/base_policy.rb', line 34 def show? end |
#update? ⇒ Boolean
50 51 52 |
# File 'lib/action_authorization/base_policy.rb', line 50 def update? end |