Class: Qonfig::Settings Private
- Inherits:
-
Object
- Object
- Qonfig::Settings
- Defined in:
- lib/qonfig/settings.rb,
lib/qonfig/settings/lock.rb,
lib/qonfig/settings/builder.rb,
lib/qonfig/settings/key_guard.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.
Defined Under Namespace
Modules: Builder Classes: KeyGuard, Lock
Instance Attribute Summary collapse
- #__options__ ⇒ Hash readonly private
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ void
- #__append_settings__(settings) ⇒ void private
- #__apply_values__(options_map) ⇒ void private
- #__clear__ ⇒ void private
- #__define_setting__(key, value) ⇒ void private
- #__dig__(*keys) ⇒ Object private
- #__freeze__ ⇒ void private
- #__is_frozen__ ⇒ Boolean private
- #__to_hash__ ⇒ Hash (also: #__to_h__) private
-
#initialize ⇒ Settings
constructor
private
A new instance of Settings.
- #method_missing(method_name, *arguments, &block) ⇒ void private
- #respond_to_missing?(method_name, include_private = false) ⇒ Boolean private
Constructor Details
#initialize ⇒ Settings
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 Settings.
17 18 19 20 |
# File 'lib/qonfig/settings.rb', line 17 def initialize = {} @__lock__ = Lock.new end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *arguments, &block) ⇒ 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.
123 124 125 126 127 |
# File 'lib/qonfig/settings.rb', line 123 def method_missing(method_name, *arguments, &block) super rescue NoMethodError ::Kernel.raise(Qonfig::UnknownSettingError, "Setting with <#{method_name}> key doesnt exist!") end |
Instance Attribute Details
#__options__ ⇒ Hash (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.
13 14 15 |
# File 'lib/qonfig/settings.rb', line 13 def end |
Instance Method Details
#[](key) ⇒ Object
65 66 67 |
# File 'lib/qonfig/settings.rb', line 65 def [](key) __lock__.thread_safe_access { __get_value__(key) } end |
#[]=(key, value) ⇒ void
This method returns an undefined value.
75 76 77 |
# File 'lib/qonfig/settings.rb', line 75 def []=(key, value) __lock__.thread_safe_access { __set_value__(key, value) } end |
#__append_settings__(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.
52 53 54 55 56 57 58 |
# File 'lib/qonfig/settings.rb', line 52 def __append_settings__(settings) __lock__.thread_safe_merge do settings..each_pair do |key, value| __define_setting__(key, value) end end end |
#__apply_values__(options_map) ⇒ 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.
84 85 86 |
# File 'lib/qonfig/settings.rb', line 84 def __apply_values__() __lock__.thread_safe_access { __set_values_from_map__() } end |
#__clear__ ⇒ 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.
110 111 112 |
# File 'lib/qonfig/settings.rb', line 110 def __clear__ __lock__.thread_safe_access { __clear_option_values__ } end |
#__define_setting__(key, value) ⇒ 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.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/qonfig/settings.rb', line 28 def __define_setting__(key, value) __lock__.thread_safe_definition do key = __indifferently_accessable_option_key__(key) __prevent_core_method_intersection__(key) case when !.key?(key) [key] = value when [key].is_a?(Qonfig::Settings) && value.is_a?(Qonfig::Settings) [key].__append_settings__(value) else [key] = value end __define_accessor__(key) end end |
#__dig__(*keys) ⇒ Object
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.
93 94 95 |
# File 'lib/qonfig/settings.rb', line 93 def __dig__(*keys) __lock__.thread_safe_access { __deep_access__(*keys) } end |
#__freeze__ ⇒ 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.
143 144 145 146 147 148 149 150 151 |
# File 'lib/qonfig/settings.rb', line 143 def __freeze__ __lock__.thread_safe_access do .freeze .each_value do |value| value.__freeze__ if value.is_a?(Qonfig::Settings) end end end |
#__is_frozen__ ⇒ Boolean
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.
157 158 159 |
# File 'lib/qonfig/settings.rb', line 157 def __is_frozen__ __lock__.thread_safe_access { .frozen? } end |
#__to_hash__ ⇒ Hash Also known as: __to_h__
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.
101 102 103 |
# File 'lib/qonfig/settings.rb', line 101 def __to_hash__ __lock__.thread_safe_access { __build_hash_representation__ } end |
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
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.
133 134 135 136 137 |
# File 'lib/qonfig/settings.rb', line 133 def respond_to_missing?(method_name, include_private = false) # :nocov: .key?(method_name.to_s) || .key?(method_name.to_sym) || super # :nocov: end |