Class: Qonfig::Commands::LoadFromJSON Private
- Defined in:
- lib/qonfig/commands/load_from_json.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Attribute Summary collapse
- #file_path ⇒ String readonly private
- #strict ⇒ Boolean readonly private
Instance Method Summary collapse
- #call(data_set, settings) ⇒ void private
-
#initialize(file_path, strict: true) ⇒ LoadFromJSON
constructor
private
A new instance of LoadFromJSON.
Constructor Details
#initialize(file_path, strict: true) ⇒ LoadFromJSON
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of LoadFromJSON.
23 24 25 26 |
# File 'lib/qonfig/commands/load_from_json.rb', line 23 def initialize(file_path, strict: true) @file_path = file_path @strict = strict end |
Instance Attribute Details
#file_path ⇒ String (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
10 11 12 |
# File 'lib/qonfig/commands/load_from_json.rb', line 10 def file_path @file_path end |
#strict ⇒ Boolean (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
16 17 18 |
# File 'lib/qonfig/commands/load_from_json.rb', line 16 def strict @strict end |
Instance Method Details
#call(data_set, settings) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/qonfig/commands/load_from_json.rb', line 34 def call(data_set, settings) json_data = Qonfig::Loaders::JSON.load_file(file_path, fail_on_unexist: strict) raise( Qonfig::IncompatibleJSONStructureError, 'JSON object should have a hash-like structure' ) unless json_data.is_a?(Hash) json_based_settings = build_data_set_klass(json_data).new.settings settings.__append_settings__(json_based_settings) end |