Method: Constance::Resolver.resolve
- Defined in:
- lib/constance/resolver.rb
.resolve(from_mod, const_name) ⇒ Object
return a constant or if returns nil, Rails will use ActiveSupport::Dependencies.load_missing_constant
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/constance/resolver.rb', line 8 def self.resolve(from_mod, const_name) if Constance.caller_search_mapping puts "#{self.class.name} checking caller stack against caller_search_mapping regular expressions #{Constance.caller_search_mapping.inspect}" if Constance.verbose? klass = resolve_by_caller_search_mapping(from_mod, const_name, Constance.caller_search_mapping) puts "#{self.class.name} caller_search_mapping did not resolve" if Constance.verbose? && !klass end if !klass && Constance.proc.is_a?(Proc) puts "#{self.class.name} sending from_mod=#{from_mod} and const_name=#{const_name} into proc" if Constance.verbose? klass = Constance.proc.call(from_mod, const_name) puts "#{self.class.name} proc did not resolve" if Constance.verbose? && !klass end # if got something and didn't ask to replace it if klass && !Store[const_name.to_sym] puts "#{self.class.name} setting #{const_name} => #{klass} on ActiveSupport::Dependencies::Reference @store" if Constance.verbose? ActiveSupport::Dependencies::Reference.instance_variable_get(:@store)[const_name] = klass if klass end klass end |