lib/finix/utils.rb in finix-0.15 vs lib/finix/utils.rb in finix-0.16

- old
+ new

@@ -1,10 +1,11 @@ module Finix module Utils - def eval_class(slf, name) - mod = slf.class.name.split("::").first unless slf.kind_of? Class or slf.kind_of? Module - mod = slf.name.split("::").first if mod.nil? + def eval_class(slf, cls) + mod = slf.class.name.sub(/::.*/, '') unless slf.kind_of? Class or slf.kind_of? Module + mod = slf.name.sub(/::.*/, '') if mod.nil? + name = demodulize cls.name self.instance_eval "#{mod}::#{name}" end def callable(callable_or_not) callable_or_not.respond_to?(:call) ? callable_or_not : lambda { callable_or_not } @@ -35,9 +36,13 @@ end end indifferent[key.to_s] = value end indifferent + end + + def demodulize(class_name_in_module) + class_name_in_module.to_s.sub(/^.*::/, '') end extend self end end \ No newline at end of file