Module: Configuration
- Includes:
- Validator
- Included in:
- Blockfrostruby::Net, Params
- Defined in:
- lib/blockfrostruby/configuration.rb
Class Method Summary collapse
-
.default_config ⇒ Object
Loads a default config from config.yml file.
-
.define_config(config) ⇒ Hash
Calling when Net subclass object creating, validate passed hash, and apply parametres to the Net object.
Methods included from Validator
validate_init_params, validate_params
Class Method Details
.default_config ⇒ Object
Loads a default config from config.yml file.
11 12 13 14 15 |
# File 'lib/blockfrostruby/configuration.rb', line 11 def default_config YAML.safe_load( File.open("#{File.dirname(__FILE__)}/config.yml").read ).transform_keys(&:to_sym) end |
.define_config(config) ⇒ Hash
Calling when Net subclass object creating, validate passed hash, and apply parametres to the Net object.
21 22 23 24 25 26 27 28 |
# File 'lib/blockfrostruby/configuration.rb', line 21 def define_config(config) result = default_config Validator.validate_init_params(config) config.each do |key, value| result[key] = value unless result[key].nil? end result end |