Sha256: 8afea64269bcd57857374bf19e5bccef591ae0ce5a2fb2972fce323e06ca73b3
Contents?: true
Size: 1.12 KB
Versions: 2
Compression:
Stored size: 1.12 KB
Contents
module Aegis module PermissionFilter def self.extended(base) base.instance_eval do def authorize_first!(current_user, options = {}) before_filter{authorize_action(current_user,options)} end protected def authorize_action(current_user,options = {}) options = {:except => []}.merge(options) options[:except] << "application" return if options[:except].include? controller_name permission_type = "" case action_name when "index","show" permission_type = Aegis::Constants::CRUD_VERBS[1] when "edit","update" permission_type = Aegis::Constants::CRUD_VERBS[2] when "new,","create" permission_type = Aegis::Constants::CRUD_VERBS[0] when "destroy" permission_type = Aegis::Constants::CRUD_VERBS[3] else permission_type = action_name end eval "#{current_user}.#{Aegis::Constants::PERMISSION_PREFIX}_#{permission_type}_#{controller_name}?" end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
thelinuxlich-aegis-1.1.9 | lib/aegis/permission_filter.rb |
thelinuxlich-aegis-1.1.8 | lib/aegis/permission_filter.rb |