Module: Formol::Permissions::Controllers::InstanceMethods
- Defined in:
- lib/formol/permissions/controllers.rb
Instance Method Summary collapse
- #formol_authorize!(user, rights, obj = nil) ⇒ Object
- #formol_authorized?(user, rights, obj = nil) ⇒ Boolean
Instance Method Details
#formol_authorize!(user, rights, obj = nil) ⇒ Object
22 23 24 25 26 |
# File 'lib/formol/permissions/controllers.rb', line 22 def (user, rights, obj = nil) unless (user, rights, obj) raise Formol::Permissions::NotAuthorizedError.new end end |
#formol_authorized?(user, rights, obj = nil) ⇒ Boolean
13 14 15 16 17 18 19 20 |
# File 'lib/formol/permissions/controllers.rb', line 13 def (user, rights, obj = nil) user = Formol.config.user.new(:formol_profile => :default) if user.nil? rights = [rights] rights.flatten! rights.any?{ |r| user.formol_allowed_to?(r, obj) } end |