Class: ConfigToolkit::HashReader
- Defined in:
- lib/configtoolkit/hashreader.rb
Overview
This class implements a no-op Reader interface. A Hash is specified in its constructor and is passed through to requesting BaseConfig instances in its read method.
This allows BaseConfig instances to be programatically loaded from Hashes. For instance,
config = SimpleConfig.load(ConfigToolkit::HashReader.new(:param1 => 1))
See Hash.txt for more details.
Instance Method Summary collapse
-
#initialize(config_hash) ⇒ HashReader
constructor
Description: This constructs a HashReader instance that will return
config_hash
in read. -
#read ⇒ Object
Returns: The Hash specified in the constructor.
Methods inherited from Reader
Constructor Details
#initialize(config_hash) ⇒ HashReader
Description:
This constructs a HashReader instance that will return config_hash
in read.
Parameters:
- config_hash
-
A Hash to be returned by read
28 29 30 |
# File 'lib/configtoolkit/hashreader.rb', line 28 def initialize(config_hash) @config_hash = config_hash end |
Instance Method Details
#read ⇒ Object
Returns:
The Hash specified in the constructor
36 37 38 |
# File 'lib/configtoolkit/hashreader.rb', line 36 def read return @config_hash end |