Class: Rudder::DSL::Component
- Inherits:
-
Object
- Object
- Rudder::DSL::Component
- Includes:
- Util
- Defined in:
- lib/rudder/dsl/component.rb
Overview
Base class for other pipeline sub components to extend
Not intended for public usage and subject to change.
Instance Method Summary collapse
-
#_inner_hash ⇒ Object
Required method for all subclasses to implement.
-
#method_missing(method, *args, **kwargs) ⇒ Object
Populates the inner hash with missing method names and their arguments.
-
#respond_to?(_name, _include_all = true) ⇒ Boolean
Components respond to everything by default.
-
#respond_to_missing?(*_) ⇒ Boolean
Components respond to missing by default.
- #to_h ⇒ Object
Methods included from Util
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, **kwargs) ⇒ Object
Populates the inner hash with missing method names and their arguments
rubocop:disable Style/MethodMissingSuper
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/rudder/dsl/component.rb', line 43 def method_missing(method, *args, **kwargs) # Accessing inner hash as attribute return _inner_hash[method] if args.empty? && kwargs.empty? # Ruby treats dictionaries passed as the last argument as keyword dicts # (specifically when they use symbols as keys). Just smashing # these into args so we don't miss anything args << kwargs unless kwargs.empty? raise "Argument list missing from [#{method}]" if args.empty? # If a single arg is given then assume this field is scalar, # otherwise assume its a list that needs all args formatted_args = args.size == 1 ? args[0] : args _inner_hash[method] = formatted_args end |
Instance Method Details
#_inner_hash ⇒ Object
Required method for all subclasses to implement.
19 20 21 |
# File 'lib/rudder/dsl/component.rb', line 19 def _inner_hash raise 'Implement this in a subclass' end |
#respond_to?(_name, _include_all = true) ⇒ Boolean
Components respond to everything by default
65 66 67 |
# File 'lib/rudder/dsl/component.rb', line 65 def respond_to?(_name, _include_all = true) true end |
#respond_to_missing?(*_) ⇒ Boolean
Components respond to missing by default
74 75 76 |
# File 'lib/rudder/dsl/component.rb', line 74 def respond_to_missing?(*_) true end |
#to_h ⇒ Object
23 24 25 |
# File 'lib/rudder/dsl/component.rb', line 23 def to_h _deep_to_h(_inner_hash) end |