Module: Datadog::Core::Configuration::Options::ClassMethods
- Defined in:
- lib/datadog/core/configuration/options.rb,
sig/datadog/core/configuration/options.rbs
Overview
Class behavior for a configuration object with options
Instance Method Summary collapse
- #default_helpers(name) ⇒ Hash[Symbol, OptionDefinition::generic_proc]
- #define_helpers(helpers) ⇒ void
- #define_method {|arg0| ... } ⇒ Object
- #options ⇒ Object
-
#settings_children ⇒ Object
Registry of nested settings classes keyed by the option name declared via
Base.settings. - #settings_path ⇒ Object
- #settings_path=(path) ⇒ Object
-
#superclass ⇒ Object
Fake methods to make it work with RBS.
Instance Method Details
#default_helpers(name) ⇒ Hash[Symbol, OptionDefinition::generic_proc]
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/datadog/core/configuration/options.rb', line 71 def default_helpers(name) option_name = name.to_sym # Steep: https://github.com/soutaro/steep/issues/335 # @type var opt_getter: Configuration::OptionDefinition::generic_proc opt_getter = proc do # steep:ignore IncompatibleAssignment # These Procs uses `get/set_option`, but we only add them to the OptionDefinition helpers here. # Steep is right that these methods are not defined, but we only run these Procs in instance context. get_option(option_name) # steep:ignore NoMethod end # Steep: https://github.com/soutaro/steep/issues/335 # @type var opt_setter: Configuration::OptionDefinition::generic_proc opt_setter = proc do |value| # steep:ignore IncompatibleAssignment set_option(option_name, value) # steep:ignore NoMethod end { option_name.to_sym => opt_getter, :"#{option_name}=" => opt_setter } end |
#define_helpers(helpers) ⇒ void
This method returns an undefined value.
91 92 93 94 95 96 97 |
# File 'lib/datadog/core/configuration/options.rb', line 91 def define_helpers(helpers) helpers.each do |name, block| next unless block.is_a?(Proc) define_method(name, &block) end end |
#define_method {|arg0| ... } ⇒ Object
73 |
# File 'sig/datadog/core/configuration/options.rbs', line 73
def define_method: (Symbol name) { (?) [self: OptionDefinition::settings_execution_context] -> untyped } -> untyped
|
#options ⇒ Object
47 48 49 50 51 52 53 54 |
# File 'lib/datadog/core/configuration/options.rb', line 47 def # Allows for class inheritance of option definitions @options ||= if superclass <= Options superclass..dup else {} end end |
#settings_children ⇒ Object
Registry of nested settings classes keyed by the option name declared
via Base.settings. This lets us propagate a new settings path down the
tree without storing parent references on the nested class or on the
option definition itself.
27 28 29 30 31 32 33 |
# File 'lib/datadog/core/configuration/options.rb', line 27 def settings_children @settings_children ||= if superclass <= Options superclass.settings_children.dup else {} end end |
#settings_path ⇒ Object
19 20 21 |
# File 'lib/datadog/core/configuration/options.rb', line 19 def settings_path defined?(@settings_path) ? @settings_path : nil end |
#settings_path=(path) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/datadog/core/configuration/options.rb', line 35 def settings_path=(path) @settings_path = path # Keep nested settings paths in sync when a parent settings path is # assigned later, which is how contrib integrations inject # "tracing.<integration>" into their configuration classes. settings_children.each do |name, settings_class| nested_settings_path = path ? "#{path}.#{name}" : name.to_s settings_class.settings_path = nested_settings_path end end |
#superclass ⇒ Object
Fake methods to make it work with RBS. RBS cannot understand that this module is only used in a class context.
72 |
# File 'sig/datadog/core/configuration/options.rbs', line 72
def superclass: () -> untyped
|