Module: WorldData

Defined in:
lib/testcentricity_web/world_extensions.rb

Instance Method Summary collapse

Instance Method Details

#environsObject



2
3
4
# File 'lib/testcentricity_web/world_extensions.rb', line 2

def environs
  @environs ||= TestCentricity::EnvironData
end

#instantiate_data_objectsObject

instantiate and register all data objects specified in data_objects method



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/testcentricity_web/world_extensions.rb', line 7

def instantiate_data_objects
  # return if data objects have already been instantiated and registered
  return if TestCentricity::DataManager.loaded?

  # instantiate all data objects
  @data = {}
  data_objects.each do |data_type, data_class|
    @data[data_type] = data_class.new unless @data.has_key?(data_type)
    # define data object accessor method
    define_method(data_type) do
      if instance_variable_defined?(:"@#{data_type}")
        instance_variable_get(:"@#{data_type}")
      else
        instance_variable_set(:"@#{data_type}", TestCentricity::DataManager.find_data_object(data_type))
      end
    end
  end
  # register all data objects with DataManager
  TestCentricity::DataManager.register_data_objects(@data)
end