Module: Cannie::ControllerExtensions
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/cannie/controller_extensions.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
-
#can?(action, on: nil) ⇒ Boolean
Checks whether passed action is permitted for passed subject.
- #current_permissions ⇒ Object
- #permitted? ⇒ Boolean
Instance Method Details
#can?(action, on: nil) ⇒ Boolean
Checks whether passed action is permitted for passed subject
can? :index, on: :entries
or
can? :index, on: EntriesController
or
can? :index, on: 'admin/entries'
59 60 61 62 |
# File 'lib/cannie/controller_extensions.rb', line 59 def can?(action, on: nil) raise Cannie::SubjectNotSetError, 'Subject should be specified' unless on .can?(action, on) end |
#current_permissions ⇒ Object
68 69 70 |
# File 'lib/cannie/controller_extensions.rb', line 68 def ||= ::Permissions.new(current_user) end |
#permitted? ⇒ Boolean
64 65 66 |
# File 'lib/cannie/controller_extensions.rb', line 64 def permitted? !!@_permitted end |