Class: Qonfig::Commands::Definition::ExposeSelf Private
- Defined in:
- lib/qonfig/commands/definition/expose_self.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
- #caller_location ⇒ String readonly private
- #env ⇒ Symbol, String readonly private
- #format ⇒ String, Symbol readonly private
- #replace_on_merge ⇒ Boolean readonly private
Instance Method Summary collapse
-
#call(data_set, settings) ⇒ void
private
rubocop:disable Metrics/AbcSize.
-
#initialize(caller_location, env:, format:, replace_on_merge: false) ⇒ ExposeSelf
constructor
private
A new instance of ExposeSelf.
Methods inherited from Base
inheritable=, inheritable?, #inheritable?, inherited
Constructor Details
#initialize(caller_location, env:, format:, replace_on_merge: false) ⇒ ExposeSelf
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 ExposeSelf.
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/qonfig/commands/definition/expose_self.rb', line 42 def initialize(caller_location, env:, format:, replace_on_merge: false) unless env.is_a?(Symbol) || env.is_a?(String) raise Qonfig::ArgumentError, ':env should be a string or a symbol' end raise Qonfig::ArgumentError, ':env should be provided' if env.to_s.empty? unless format.is_a?(String) || format.is_a?(Symbol) raise Qonfig::ArgumentError, 'Format should be a symbol or a string' end @caller_location = caller_location @env = env @format = format.tap { Qonfig::Loaders.resolve(format) } @replace_on_merge = replace_on_merge end |
Instance Attribute Details
#caller_location ⇒ 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.
20 21 22 |
# File 'lib/qonfig/commands/definition/expose_self.rb', line 20 def caller_location @caller_location end |
#env ⇒ Symbol, 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.
26 27 28 |
# File 'lib/qonfig/commands/definition/expose_self.rb', line 26 def env @env end |
#format ⇒ String, Symbol (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/expose_self.rb', line 14 def format @format 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.
32 33 34 |
# File 'lib/qonfig/commands/definition/expose_self.rb', line 32 def replace_on_merge @replace_on_merge 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.
rubocop:disable Metrics/AbcSize
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/qonfig/commands/definition/expose_self.rb', line 67 def call(data_set, settings) self_placed_data = load_self_placed_end_data env_based_data_slice = self_placed_data[env] || self_placed_data[env.to_s] || self_placed_data[env.to_sym] raise( Qonfig::ExposeError, "#{file_path} file does not contain settings with <#{env}> environment key!" ) unless env_based_data_slice raise( Qonfig::IncompatibleEndDataStructureError, '__END__-data content must be a hash-like structure' ) unless env_based_data_slice.is_a?(Hash) self_placed_settings = build_data_set_klass(env_based_data_slice).new.settings settings.__append_settings__(self_placed_settings, with_redefinition: replace_on_merge) end |