Class: OpenConfig::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/open_config/files/base.rb

Direct Known Subclasses

JSON, YAML

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root: Dir.pwd, file:) ⇒ Base

Returns a new instance of Base.



7
8
9
# File 'lib/open_config/files/base.rb', line 7

def initialize(root: Dir.pwd, file:)
  @file_path = File.join(root, file)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *arguments, &block) ⇒ Object



11
12
13
14
15
# File 'lib/open_config/files/base.rb', line 11

def method_missing(method_name, *arguments, &block)
  return super unless configuration_method?(method_name)

  tree.public_send(method_name, *arguments, &block)
end

Instance Attribute Details

#file_pathObject (readonly)

Returns the value of attribute file_path.



5
6
7
# File 'lib/open_config/files/base.rb', line 5

def file_path
  @file_path
end

Instance Method Details

#respond_to_missing?(method_name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/open_config/files/base.rb', line 17

def respond_to_missing?(method_name, include_private = false)
  configuration_method?(method_name) || super
end