Class: TYCiCore::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/tuya/ci/core/config.rb

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Config

Returns a new instance of Config.



3
4
5
6
7
# File 'lib/tuya/ci/core/config.rb', line 3

def initialize(path)
	raise "Can not find config at : #{path}" unless File.exist? path
	@content = File.read path
	@content_json = JSON @content
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/tuya/ci/core/config.rb', line 13

def method_missing(name)
	if @content_json.has_key? name.to_s
		@content_json[name.to_s]
	else
		super.method_missing name
	end
end

Instance Method Details

#value(key) ⇒ Object



9
10
11
# File 'lib/tuya/ci/core/config.rb', line 9

def value(key)
	eval("@content_json" << key.split('.').map { |i| "[\"" + i + "\"]" }.join)
end