Class: PairKit::DslFactory::Wrapper
- Inherits:
-
Object
- Object
- PairKit::DslFactory::Wrapper
- Defined in:
- lib/pair_kit/dsl_factory/wrapper.rb
Instance Method Summary collapse
-
#initialize(name, builder) ⇒ Wrapper
constructor
A new instance of Wrapper.
- #method_missing(method_name, *args, **kw_args, &block) ⇒ Object
- #respond_to_missing?(method_name, include_private = false) ⇒ Boolean
Constructor Details
#initialize(name, builder) ⇒ Wrapper
Returns a new instance of Wrapper.
4 5 6 7 |
# File 'lib/pair_kit/dsl_factory/wrapper.rb', line 4 def initialize(name, builder) @name = name @builder = builder end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, **kw_args, &block) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/pair_kit/dsl_factory/wrapper.rb', line 13 def method_missing(method_name, *args, **kw_args, &block) if @builder.respond_to?(method_name) builder_return = @builder.public_send(method_name, *args, **kw_args, &block) if block self else builder_return.is_a?(Wrapper) ? builder_return : self end else raise "Method missing #{method_name} for builder #{@name}" end end |
Instance Method Details
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
9 10 11 |
# File 'lib/pair_kit/dsl_factory/wrapper.rb', line 9 def respond_to_missing?(method_name, include_private = false) @builder.respond_to?(method_name) || super end |