Module: Codeine::Utility
- Defined in:
- lib/codeine.rb
Class Method Summary collapse
Class Method Details
.constant_path(constant) ⇒ Object
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/codeine.rb', line 44 def constant_path(constant) constants = [] parts = constant.to_s.split("::") parts.count.times do |i| constants << parts[0..i].inject(Kernel) do |memo, obj| memo.const_get(obj) end end constants end |
.nearest_container(constant) ⇒ Object
55 56 57 58 59 60 61 62 |
# File 'lib/codeine.rb', line 55 def nearest_container(constant) container = nil constant_path(constant).reverse.each do |c| next unless c.respond_to? :codeine_container break if container = c.codeine_container end container || ::Codeine.default_container end |