Class: Greenpeace::Environment

Inherits:
Object
  • Object
show all
Defined in:
lib/greenpeace/environment.rb

Overview

Environment accessor object

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Environment

Returns a new instance of Environment.



6
7
8
9
10
11
12
# File 'lib/greenpeace/environment.rb', line 6

def initialize(config)
  @values = {}

  config.settings.each do |setting|
    @values[setting.identifier] = setting.value
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/greenpeace/environment.rb', line 14

def method_missing(method)
  value = method.to_s
  if @values.key?(value)
    @values[value]
  else
    super
  end
end

Instance Attribute Details

#valuesObject (readonly)

Returns the value of attribute values.



4
5
6
# File 'lib/greenpeace/environment.rb', line 4

def values
  @values
end