Class: Reading::Config

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

Overview

Builds a singleton hash config.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(custom_config = {}) ⇒ Config

Returns a new instance of Config.

Parameters:

  • custom_config (Hash) (defaults to: {})

    a custom config which overrides the defaults, e.g. { enabled_columns: [:head, :end_dates] }



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

def initialize(custom_config = {})
  @custom_config = custom_config

  build_hash
end

Instance Attribute Details

#hashObject (readonly)

Returns the value of attribute hash.



9
10
11
# File 'lib/reading/config.rb', line 9

def hash
  @hash
end

Class Method Details

.build(custom_config = {}) ⇒ Hash

Builds an entire config hash from a custom config hash (which is typically not an entire config, but it can be, in which case a copy is returned).

Parameters:

Returns:



15
16
17
# File 'lib/reading/config.rb', line 15

def self.build(custom_config = {})
  @hash = new(custom_config).hash
end

.hashHash

Returns:



20
21
22
# File 'lib/reading/config.rb', line 20

def self.hash
  @hash ||= build
end