Class: Barristan::Can
- Inherits:
-
Object
- Object
- Barristan::Can
- Defined in:
- lib/barristan.rb
Instance Method Summary collapse
- #able? ⇒ Boolean
-
#initialize(resource, action, user) ⇒ Can
constructor
A new instance of Can.
Constructor Details
#initialize(resource, action, user) ⇒ Can
Returns a new instance of Can.
22 23 24 25 26 27 |
# File 'lib/barristan.rb', line 22 def initialize(resource, action, user) @resource = resource @klass = resource.class == Class ? resource : resource.class @action = action @user = user end |
Instance Method Details
#able? ⇒ Boolean
29 30 31 |
# File 'lib/barristan.rb', line 29 def able? send("#{action}_#{klass.to_s.downcase}?", resource, user) end |