Sha256: 5ee46a7b9defcc4a195532249ca41fa8f1fd62ec90d0ec5881c72b087c2395c7
Contents?: true
Size: 779 Bytes
Versions: 3
Compression:
Stored size: 779 Bytes
Contents
module Formol module Permissions class NotAuthorizedError < Exception; end module Controllers extend ActiveSupport::Concern included do helper_method :formol_authorized? end module InstanceMethods def formol_authorized?(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 def formol_authorize!(user, rights, obj = nil) unless formol_authorized?(user, rights, obj) raise Formol::Permissions::NotAuthorizedError.new end end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
formol-0.0.6 | lib/formol/permissions/controllers.rb |
formol-0.0.5 | lib/formol/permissions/controllers.rb |
formol-0.0.4 | lib/formol/permissions/controllers.rb |