Class: AutoData::Data
- Inherits:
-
Object
- Object
- AutoData::Data
- Defined in:
- lib/auto_data.rb
Instance Method Summary collapse
-
#chage_scope(data_key) ⇒ Object
Change data key path.
-
#change_scope(data) ⇒ Object
Change environment key path.
-
#initialize ⇒ Data
constructor
A new instance of Data.
- #load(file) ⇒ Object
- #method_missing(method) ⇒ Object
-
#valid_data? ⇒ Boolean
TODO: Validar si el cambio de data scope, es correcto (existe).
Constructor Details
#initialize ⇒ Data
Returns a new instance of Data.
6 7 8 |
# File 'lib/auto_data.rb', line 6 def initialize() @data=ENV['CONF_DATA_TEST'].to_s.downcase end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method) ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/auto_data.rb', line 32 def method_missing (method) result= begin @file["#{@data}"]["#{method}"].nil? ? 'No Value Found' : @file["#{@data}"]["#{method}"] rescue NoMethodError => e puts "valdio dick #{e.message}" end result end |
Instance Method Details
#chage_scope(data_key) ⇒ Object
Change data key path
27 28 29 |
# File 'lib/auto_data.rb', line 27 def chage_scope(data_key) @data=data_key.to_s.downcase end |
#change_scope(data) ⇒ Object
Change environment key path
22 23 24 |
# File 'lib/auto_data.rb', line 22 def change_scope(data) @data=data.to_s.downcase end |
#load(file) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/auto_data.rb', line 10 def load(file) #@file = YAML.load_file(file) @file = begin YAML.load(File.open(file)) rescue Exception => e #ArgumentError puts "Could not parse auto objects files: #{e.message}" raise Exception.new('Could not parse auto objects files: #{e.message}') end #self end |
#valid_data? ⇒ Boolean
TODO: Validar si el cambio de data scope, es correcto (existe)
43 44 45 |
# File 'lib/auto_data.rb', line 43 def valid_data? end |