Sha256: 72ebd200296e45a5d4c180eff7430cf2c2a0b74644b9961f18e0820732bb8d42
Contents?: true
Size: 620 Bytes
Versions: 6
Compression:
Stored size: 620 Bytes
Contents
module Dependor class ClassNameResolver attr_reader :search_modules def initialize(search_modules) @search_modules = search_modules end def for_name(name) class_name = camelize(name) modules = search_modules.concat([Object]) klass = nil modules.each do |mod| klass = mod.const_get(class_name) rescue nil break if klass end klass end private def camelize(symbol) string = symbol.to_s string = string.gsub(/_\w/) { |match| match[1].upcase } return string.gsub(/^\w/) { |match| match.upcase } end end end
Version data entries
6 entries across 6 versions & 1 rubygems