Class: Rdm::ConfigScope

Inherits:
Object
  • Object
show all
Defined in:
lib/rdm/config_scope.rb

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ ConfigScope

Returns a new instance of ConfigScope.



2
3
4
# File 'lib/rdm/config_scope.rb', line 2

def initialize(attributes = {})
  @attributes = attributes
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *_args) ⇒ Object



14
15
16
# File 'lib/rdm/config_scope.rb', line 14

def method_missing(method_name, *_args)
  read_attribute(method_name)
end

Instance Method Details

#read_attribute(key) ⇒ Object



6
7
8
# File 'lib/rdm/config_scope.rb', line 6

def read_attribute(key)
  @attributes[key.to_s]
end

#to_hObject



18
19
20
21
22
# File 'lib/rdm/config_scope.rb', line 18

def to_h
  @attributes.each_with_object({}) do |(k, v), h|
    h[k] = Rdm::ConfigScope === v ? v.to_h : v
  end
end

#write_attribute(key, value) ⇒ Object



10
11
12
# File 'lib/rdm/config_scope.rb', line 10

def write_attribute(key, value)
  @attributes[key.to_s] = value
end