Sha256: 8ee3876804ebf669eb90337efbbf215bd3c453ded0b3a4a7bab960abef8fd2b1
Contents?: true
Size: 1.74 KB
Versions: 1
Compression:
Stored size: 1.74 KB
Contents
module CanTango class PermitEngine < Engine autoload_modules :Builder, :Compatibility, :Executor autoload_modules :Factory, :Finder, :Loaders, :Util, :RoleMatcher include CanTango::Ability::Executor include CanTango::Ability::RoleHelpers include CanTango::Ability::UserHelpers def initialize ability super end def permit_rules # push result of each permit type execution into main ability rules array permits.each_pair do |type, permits| perm_rules = executor(type, permits).execute! rules << perm_rules if !perm_rules.blank? end end def executor type, permits CanTango::Permits::Executor.new self, type, permits end def engine_name :permit end def valid? return false if !valid_mode? permits.empty? ? invalid : true end # by default, only execute permits for which the user # has a role or a role group # also execute any permit marked as special def permits @permits ||= permit_factory.build! end def permit_class_names @permit_class_names ||= permits.map{|p| p.class.to_s} end protected alias_method :cache_key, :engine_name def start_execute debug "Permit Engine executing..." end def end_execute debug "Done Permit Engine" end def invalid debug "No permits found!" false end def permit_factory @permit_factory ||= CanTango::PermitEngine::Factory.new self end def key_method_names permits.keys.map {|type| key type }.compact end def key type case type when :role roles_list_meth when :role_group role_groups_list_meth else nil end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
cantango-0.9.4 | lib/cantango/permit_engine.rb |