Module: Symbiont::DataBuilder

Extended by:
DataReader
Defined in:
lib/symbiont/data_builder.rb

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from DataReader

data_path, data_path=, load

Class Attribute Details

.data_sourceObject

Returns the value of attribute data_source.



6
7
8
# File 'lib/symbiont/data_builder.rb', line 6

def data_source
  @data_source
end

Class Method Details

.default_data_pathObject



8
9
10
# File 'lib/symbiont/data_builder.rb', line 8

def default_data_path
  'data'
end

Instance Method Details

#data_about(key, specified = {}) ⇒ Object Also known as: data_from, data_for, using_data_for, using_data_from

Raises:

  • (ArgumentError)


13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/symbiont/data_builder.rb', line 13

def data_about(key, specified = {})
  if key.is_a?(String) && key.match(%r{/})
    file, record = key.split('/')
    DataBuilder.load("#{file}.yml")
  else
    record = key.to_s
    DataBuilder.load('default.yml')
  end

  Symbiont.trace("DataBuilder.data_source = #{DataBuilder.data_source}")

  data = DataBuilder.data_source[record]
  raise ArgumentError, "Undefined key for data: #{key}" unless data

  data.merge(specified)
end