Sha256: 60549a4da0eaeefd75e95f99bdc12340e647191c41ed463fa07f30a262aebb01
Contents?: true
Size: 903 Bytes
Versions: 15
Compression:
Stored size: 903 Bytes
Contents
module Ecoportal module API module Common module BaseClass def redef_without_warning(const, value) self.class.send(:remove_const, const) if self.class.const_defined?(const) self.class.const_set(const, value) end 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
Version data entries
15 entries across 15 versions & 1 rubygems