Class: RubyAPI::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_api/config.rb

Overview

Config data

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Config

Returns a new instance of Config.



10
11
12
# File 'lib/ruby_api/config.rb', line 10

def initialize(data)
  @data = prep_data(data)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object



26
27
28
29
# File 'lib/ruby_api/config.rb', line 26

def method_missing(name, *args)
  return @data[name.to_sym] if respond_to_missing?(name.to_sym)
  super
end

Class Method Details

.from_file(path) ⇒ Object



6
7
8
# File 'lib/ruby_api/config.rb', line 6

def self.from_file(path)
  new(YAML.load_file(path))
end

Instance Method Details

#key?(key) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/ruby_api/config.rb', line 18

def key?(key)
  @data.key?(key)
end

#merge!(data) ⇒ Object



14
15
16
# File 'lib/ruby_api/config.rb', line 14

def merge!(data)
  @data.merge! prep_data(data)
end

#respond_to_missing?(name) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/ruby_api/config.rb', line 22

def respond_to_missing?(name, *)
  @data.key?(name)
end