Module: Constellation::InstanceMethods

Includes:
Enumerable
Defined in:
lib/constellation.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *arguments, &block) ⇒ Object



45
46
47
48
49
50
51
# File 'lib/constellation.rb', line 45

def method_missing(name, *arguments, &block)
  if data.has_key?(name.to_s)
    data[name.to_s]
  else
    super
  end
end

Instance Method Details

#[](key) ⇒ Object



37
38
39
# File 'lib/constellation.rb', line 37

def [](key)
  @data[key.to_s]
end

#each(&block) ⇒ Object



41
42
43
# File 'lib/constellation.rb', line 41

def each(&block)
  @data.each &block
end

#initialize(data = nil) ⇒ Object



23
24
25
26
27
28
29
30
31
# File 'lib/constellation.rb', line 23

def initialize(data = nil)
  @data = {}
  indifferentize!
  reverse_merge(data || {})
  fall_back_on_env
  fall_back_on_file(Dir.pwd)
  fall_back_on_file(ENV['HOME'])
  fall_back_on_gems
end

#respond_to?(name) ⇒ Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/constellation.rb', line 53

def respond_to?(name)
  data.has_key?(name.to_s) || super
end

#to_hashObject



33
34
35
# File 'lib/constellation.rb', line 33

def to_hash
  @data.dup
end