Module: Cannie::Permissions
- Included in:
- Permissions
- Defined in:
- lib/cannie/permissions.rb
Defined Under Namespace
Modules: ClassMethods
Instance Attribute Summary collapse
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Class Method Summary collapse
Instance Method Summary collapse
-
#can?(action, subject) ⇒ Boolean
Checks if at least one rule for specified action add subject is present.
- #initialize(user) ⇒ Object
-
#permit!(action, subject) ⇒ Object
Raises error Cannie::ActionForbidden if there is no rules for specified action and subject.
Instance Attribute Details
#user ⇒ Object (readonly)
Returns the value of attribute user.
44 45 46 |
# File 'lib/cannie/permissions.rb', line 44 def user @user end |
Class Method Details
.included(base) ⇒ Object
3 4 5 |
# File 'lib/cannie/permissions.rb', line 3 def self.included(base) base.extend ClassMethods end |
Instance Method Details
#can?(action, subject) ⇒ Boolean
Checks if at least one rule for specified action add subject is present
55 56 57 |
# File 'lib/cannie/permissions.rb', line 55 def can?(action, subject) rules_for(action, subject).present? end |
#initialize(user) ⇒ Object
46 47 48 |
# File 'lib/cannie/permissions.rb', line 46 def initialize(user) @user = user end |
#permit!(action, subject) ⇒ Object
Raises error Cannie::ActionForbidden if there is no rules for specified action and subject
63 64 65 |
# File 'lib/cannie/permissions.rb', line 63 def permit!(action, subject) raise Cannie::ActionForbidden unless can?(action, subject) end |