Class: Payload::PartialInstance
- Inherits:
-
Object
- Object
- Payload::PartialInstance
- Defined in:
- lib/payload/partial_instance.rb
Overview
Returned by Factory#apply.
Used to build up arguments for invoking factory definitions.
Instance Method Summary collapse
- #apply(*positional, **keywords) ⇒ Object
-
#initialize(instance, positional = [], keywords = {}) ⇒ PartialInstance
constructor
private
Used internally by Factory.
-
#method_missing(name, *positional, **keywords, &block) ⇒ Object
Applies final arguments and invokes the missing method on the target.
Constructor Details
#initialize(instance, positional = [], keywords = {}) ⇒ PartialInstance
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.
Used internally by Factory.
11 12 13 14 15 |
# File 'lib/payload/partial_instance.rb', line 11 def initialize(instance, positional = [], keywords = {}) @instance = instance @positional = positional @keywords = keywords end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *positional, **keywords, &block) ⇒ Object
Applies final arguments and invokes the missing method on the target.
29 30 31 |
# File 'lib/payload/partial_instance.rb', line 29 def method_missing(name, *positional, **keywords, &block) apply(*positional, **keywords).evaluate(name, &block) end |
Instance Method Details
#apply(*positional, **keywords) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/payload/partial_instance.rb', line 18 def apply(*positional, **keywords) self.class.new( @instance, @positional + positional, @keywords.merge(keywords) ) end |