Class: Euston::RabbitMq::ConstantLoader

Inherits:
Object
  • Object
show all
Includes:
Hollywood
Defined in:
lib/euston-rabbitmq/reflection/constant_loader.rb

Instance Method Summary collapse

Instance Method Details

#load(string) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/euston-rabbitmq/reflection/constant_loader.rb', line 6

def load string
  namespace = Object
  found = true

  string.split('::').each do |segment|
    if found && namespace.const_defined?(segment)
      namespace = namespace.const_get segment.to_sym
    else
      found = false
    end
  end

  if found
    callback :hit, namespace
  else
    callback :miss, string
  end
end