Module: DataSet::DataAccessor
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(*args, &block) ⇒ Object
5
6
7
8
9
10
11
12
13
|
# File 'lib/data_set/data_accessor.rb', line 5
def method_missing(*args, &block)
load_data_source unless @data_source
key = args.first
value = @data_source[key.to_s]
value = args[1] if value.nil?
super if value.nil?
value = DataSet::DataElement.new(value) unless type_known?(value)
value
end
|
Instance Method Details
#load_data_source ⇒ Object
17
18
19
20
21
22
|
# File 'lib/data_set/data_accessor.rb', line 17
def load_data_source
@data_source = nil
path = "#{data_path}/#{ENV['DATA_SET_FILE']}"
@yml = YAML.load_file path if ENV['DATA_SET_FILE']
DataSet.load('default.yml') if @data_set.nil?
end
|
#respond_to_missing? ⇒ Boolean
15
|
# File 'lib/data_set/data_accessor.rb', line 15
def respond_to_missing?; end
|