Class: Yabeda::DSL::OptionBuilder
- Inherits:
-
Object
- Object
- Yabeda::DSL::OptionBuilder
- Extended by:
- Dry::Initializer
- Defined in:
- lib/yabeda/dsl/option_builder.rb
Overview
Collects options for metric initializer
Instance Attribute Summary collapse
-
#metric_klass ⇒ Object
readonly
Reader method for the
metric_klass
initializer parameter. -
#options ⇒ Object
readonly
Reader method for the
options
initializer parameter.
Instance Method Summary collapse
- #initialize(metric_klass, options) ⇒ Object constructor
- #method_missing(method_name, method_args, &_block) ⇒ Object
- #options_from(&block) ⇒ Object
- #respond_to_missing?(method_name, _args) ⇒ Boolean
Constructor Details
#initialize(metric_klass, options) ⇒ Object
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, method_args, &_block) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/yabeda/dsl/option_builder.rb', line 21 def method_missing(method_name, method_args, &_block) if kwarg?(method_name) [method_name] = method_args else super end end |
Instance Attribute Details
#metric_klass ⇒ Object (readonly)
Reader method for the metric_klass
initializer parameter.
9 |
# File 'lib/yabeda/dsl/option_builder.rb', line 9 param :metric_klass |
#options ⇒ Object (readonly)
Reader method for the options
initializer parameter.
10 |
# File 'lib/yabeda/dsl/option_builder.rb', line 10 param :options |
Instance Method Details
#options_from(&block) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/yabeda/dsl/option_builder.rb', line 12 def (&block) instance_eval(&block) if block return if .empty? raise ConfigurationError, "option '#{.first}' is not available for #{metric_klass.name}" end |
#respond_to_missing?(method_name, _args) ⇒ Boolean
29 30 31 |
# File 'lib/yabeda/dsl/option_builder.rb', line 29 def respond_to_missing?(method_name, _args) kwarg?(method_name) || super end |