Class: Pipes::Pipe
- Inherits:
-
Object
show all
- Defined in:
- lib/codequest_pipes/pipe.rb
Overview
Pipe is a mix-in which turns a class into a Pipes building block (Pipe). A Pipe can only have class methods since it can’t be instantiated.
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(ctx) ⇒ Pipe
Returns a new instance of Pipe.
7
8
9
|
# File 'lib/codequest_pipes/pipe.rb', line 7
def initialize(ctx)
@context = ctx
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
72
73
74
|
# File 'lib/codequest_pipes/pipe.rb', line 72
def method_missing(name, *args, &block)
context.send(name, *args, &block)
end
|
Instance Attribute Details
#context ⇒ Object
Returns the value of attribute context.
5
6
7
|
# File 'lib/codequest_pipes/pipe.rb', line 5
def context
@context
end
|
Class Method Details
.call(ctx) ⇒ Object
22
23
24
25
26
27
|
# File 'lib/codequest_pipes/pipe.rb', line 22
def self.call(ctx)
return ctx if ctx.error
_validate_ctx(_required_context_elements, ctx)
new(ctx).call
_validate_ctx(_provided_context_elements, ctx)
end
|
.provide_context(*args) ⇒ Object
33
34
35
|
# File 'lib/codequest_pipes/pipe.rb', line 33
def self.provide_context(*args)
_provided_context_elements.push(*args)
end
|
.require_context(*args) ⇒ Object
29
30
31
|
# File 'lib/codequest_pipes/pipe.rb', line 29
def self.require_context(*args)
_required_context_elements.push(*args)
end
|
.|(other) ⇒ Object
15
16
17
18
19
20
|
# File 'lib/codequest_pipes/pipe.rb', line 15
def self.|(other)
this = self
Class.new(Pipe) do
_combine(this, other)
end
end
|
Instance Method Details
#call ⇒ Object
11
12
13
|
# File 'lib/codequest_pipes/pipe.rb', line 11
def call
fail MissingCallMethod
end
|