module Ecoportal module API module Common module BaseClass def class_resolver(name, klass) define_singleton_method(name) { resolve_class(klass) } define_method(name) { self.class.resolve_class(klass) } end def resolve_class(klass) @resolved ||= {} @resolved[klass] ||= case klass when Class klass when String Kernel.const_get(klass) when Symbol resolve_class(self.send(klass)) else raise "Unknown class: #{klass}" end end end end end end