lib/lotu/behaviors/system_user.rb in lotu-0.1.18 vs lib/lotu/behaviors/system_user.rb in lotu-0.1.19

- old
+ new

@@ -5,10 +5,12 @@ def self.included base base.extend ClassMethods end + # PONDER: Cambiar por initialize? y controlar el punto de llamado + # con super? def init_behavior user_opts super if defined? super @systems ||= Hash.new options_for_me = self.class.behavior_options[SystemUser] @@ -38,9 +40,26 @@ end end # Allows to activate a system in the host module ClassMethods + # specify the systems you want to use, using symbols + # instead of module names + def use_systems *system_names + system_names.each do |system_name| + if system_name.is_a? Symbol + use Lotu.const_get("#{system_name.capitalize}System") + elsif system_name.is_a? Hash + system_name.each do |key,value| + use Lotu.const_get("#{key.capitalize}System"), value + end + else + raise "Unsupported system name as #{system_name.class}" + end + end + end + + # specify the systems you want to use, using module names def use( klass, opts={} ) behavior_options[SystemUser] ||= Hash.new behavior_options[SystemUser][klass] = opts end end