Sha256: 509c92139324a8c644a95a70a5d4ba098f96c6e9ea319b9153cb1cff29668d2f
Contents?: true
Size: 1.36 KB
Versions: 1
Compression:
Stored size: 1.36 KB
Contents
module CanTango class PermitEngine < Engine class Factory attr_accessor :ability # creates the factory for the ability # note that the ability contains the roles and role groups of the user (or account) # @param [Permits::Ability] the ability def initialize ability @ability = ability end def build! puts "PermitEngine Factory: No permits could be built" if permits.empty? && CanTango.debug? permits end def permits @permits ||= builders.inject([]) do |permits, builder| puts "++ Permit Builder: #{builder_class builder}" built_permits = permits_built_with(builder) puts "== Permits built: #{built_permits.size}" permits = permits + built_permits if built_permits end.flatten end def permits_built_with builder create_builder(builder).build end def create_builder builder clazz = builder_class(builder) clazz.constantize.new(ability) end def builder_class builder return "CanTango::PermitEngine::Builder::SpecialPermits" if builder == :special "CanTango::Permits::#{builder.to_s.camelize}Permit::Builder" end def builders [:role_group, :role, :user, :account, :special] end def options ability.options end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
cantango-0.8.8 | lib/cantango/permit_engine/factory.rb |