Class: AutoData::Env
- Inherits:
-
Object
- Object
- AutoData::Env
- Defined in:
- lib/auto_data.rb
Instance Method Summary collapse
-
#change_scope(env) ⇒ Object
Change environment key path.
-
#initialize ⇒ Env
constructor
A new instance of Env.
- #load(file) ⇒ Object
- #method_missing(method) ⇒ Object
-
#valid_environment? ⇒ Boolean
TODO: Validar si el cambio de env, es correcto (existe).
Constructor Details
#initialize ⇒ Env
Returns a new instance of Env.
51 52 53 |
# File 'lib/auto_data.rb', line 51 def initialize() @env = ENV['CONF_ENV_TEST'].to_s.downcase end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method) ⇒ Object
70 71 72 73 74 75 76 |
# File 'lib/auto_data.rb', line 70 def method_missing (method) result= begin @file["#{@env}"]["#{method}"].nil? ? 'No Value Found' : @file["#{@env}"]["#{method}"] rescue NoMethodError => e puts "valdio dick #{e.message}" end result end |
Instance Method Details
#change_scope(env) ⇒ Object
Change environment key path
66 67 68 |
# File 'lib/auto_data.rb', line 66 def change_scope(env) @env=env.to_s.downcase end |
#load(file) ⇒ Object
55 56 57 58 59 60 61 62 63 64 |
# File 'lib/auto_data.rb', line 55 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}" e.exception('adsfasdfas') end #self end |
#valid_environment? ⇒ Boolean
TODO: Validar si el cambio de env, es correcto (existe)
79 80 81 |
# File 'lib/auto_data.rb', line 79 def valid_environment? end |