Class: DotHash::Settings

Inherits:
Object
  • Object
show all
Defined in:
lib/dot_hash/settings.rb

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(configs, wrapper = Properties) ⇒ Settings

Returns a new instance of Settings.



5
6
7
# File 'lib/dot_hash/settings.rb', line 5

def initialize(configs, wrapper=Properties)
  @configs = wrapper.new(configs)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(key, *args, &block) ⇒ Object



9
10
11
# File 'lib/dot_hash/settings.rb', line 9

def method_missing(key, *args, &block)
  configs.send(key, *args, &block)
end

Class Attribute Details

.instanceObject (readonly)

Returns the value of attribute instance.



18
19
20
# File 'lib/dot_hash/settings.rb', line 18

def instance
  @instance
end

Instance Attribute Details

#configsObject (readonly)

Returns the value of attribute configs.



3
4
5
# File 'lib/dot_hash/settings.rb', line 3

def configs
  @configs
end

Class Method Details

.load(*args) ⇒ Object



28
29
30
# File 'lib/dot_hash/settings.rb', line 28

def load(*args)
  @instance = new HashLoader.new(*args).load
end

.method_missing(key, *args, &block) ⇒ Object



20
21
22
# File 'lib/dot_hash/settings.rb', line 20

def method_missing(key, *args, &block)
  instance.public_send key, *args, &block
end

.namespace(namespace) ⇒ Object



32
33
34
# File 'lib/dot_hash/settings.rb', line 32

def namespace(namespace)
  @instance = @instance[namespace]
end

.respond_to?(key) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/dot_hash/settings.rb', line 24

def respond_to?(key)
  super(key) || instance.respond_to?(key)
end

Instance Method Details

#respond_to?(key) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/dot_hash/settings.rb', line 13

def respond_to?(key)
  configs.respond_to?(key)
end