Method: DataBuilder#data_about

Defined in:
lib/data_builder.rb

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

Raises:

  • (ArgumentError)


55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/data_builder.rb', line 55

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(builder_source) unless DataBuilder.data_contents
  end

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

  # rubocop:disable Metrics/LineLength
  process_data(data.merge(specified.key?(record) ? specified[record] : specified).deep_copy)
  # rubocop:enable Metrics/LineLength
end