Class: Qonfig::Commands::Definition::LoadFromJSON Private
- Defined in:
- lib/qonfig/commands/definition/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, Pathname readonly private
- #replace_on_merge ⇒ Boolean readonly private
- #strict ⇒ Boolean readonly private
Instance Method Summary collapse
- #call(data_set, settings) ⇒ void private
-
#initialize(file_path, strict: true, replace_on_merge: false) ⇒ LoadFromJSON
constructor
private
A new instance of LoadFromJSON.
Methods inherited from Base
inheritable=, inheritable?, #inheritable?, inherited
Constructor Details
#initialize(file_path, strict: true, replace_on_merge: false) ⇒ 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.
35 36 37 38 39 |
# File 'lib/qonfig/commands/definition/load_from_json.rb', line 35 def initialize(file_path, strict: true, replace_on_merge: false) @file_path = file_path @strict = strict @replace_on_merge = replace_on_merge end |
Instance Attribute Details
#file_path ⇒ String, Pathname (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.
14 15 16 |
# File 'lib/qonfig/commands/definition/load_from_json.rb', line 14 def file_path @file_path end |
#replace_on_merge ⇒ 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.
26 27 28 |
# File 'lib/qonfig/commands/definition/load_from_json.rb', line 26 def replace_on_merge @replace_on_merge 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.
20 21 22 |
# File 'lib/qonfig/commands/definition/load_from_json.rb', line 20 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.
48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/qonfig/commands/definition/load_from_json.rb', line 48 def call(data_set, settings) json_data = Qonfig::Loaders::JSON.load_file(file_path, fail_on_unexist: strict) raise( Qonfig::IncompatibleJSONStructureError, 'JSON object must be 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, with_redefinition: replace_on_merge) end |