Module: Authorizr::Model::ClassMethods
- Defined in:
- lib/authorizr/model.rb
Instance Method Summary collapse
- #authorize(params = {}) ⇒ Object
-
#controller ⇒ Object
Attempts to find the controller class for this model using railsy style Override this method if you use nonstandard controller names…
- #permissable ⇒ Object
Instance Method Details
#authorize(params = {}) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/authorizr/model.rb', line 16 def params={} params[:user] ||= nil params[:resource] ||= nil params[:action] ||= nil troller = self.controller if troller.respond_to? :manually_authorize troller. params else raise NoMethodError, "#{troller.name} does not respond to :manually_authorize" end end |
#controller ⇒ Object
Attempts to find the controller class for this model using railsy style Override this method if you use nonstandard controller names…
7 8 9 10 11 12 13 14 |
# File 'lib/authorizr/model.rb', line 7 def controller guess = ActiveSupport::Inflector.pluralize(self.name) + 'Controller' begin troller = Object.const_get guess rescue NameError nil end end |
#permissable ⇒ Object
29 30 31 32 33 |
# File 'lib/authorizr/model.rb', line 29 def permissable self.class_eval do include Authorizr::Model::Permissable end #block end |