Class: HasConfiguration::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/has_configuration/configuration.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(klass, options = {}) ⇒ Configuration

Returns a new instance of Configuration.



9
10
11
12
13
14
15
# File 'lib/has_configuration/configuration.rb', line 9

def initialize(klass, options = {})
  @class_name = klass.name
  @options    = options

  load_file
  init_hash
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(sym, *args, &block) ⇒ Object (private)



27
28
29
# File 'lib/has_configuration/configuration.rb', line 27

def method_missing(sym, *args, &block)
  configuration.send(sym, *args, &block) || super
end

Instance Method Details

#to_h(type = nil) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/has_configuration/configuration.rb', line 17

def to_h(type = nil)
  case type
  when :symbolized  then  deep_symbolized_hash
  when :stringify   then  deep_stringified_hash
  else                    @hash
  end
end