Class: Chainer::Method
- Inherits:
-
Object
- Object
- Chainer::Method
- Defined in:
- lib/chainer/method.rb
Overview
Pipes method names on a context class
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Context to call piped methods on.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#>>(method_name) ⇒ self
The “pipe” operator.
-
#initialize(context, value) ⇒ Method
constructor
Initializes pipe wrapper.
Constructor Details
#initialize(context, value) ⇒ Method
Initializes pipe wrapper
17 18 19 20 21 |
# File 'lib/chainer/method.rb', line 17 def initialize(context, value) @context = context @value = value.is_a?(self.class) ? value.value : value freeze end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns Context to call piped methods on.
11 12 13 |
# File 'lib/chainer/method.rb', line 11 def context @context end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
11 |
# File 'lib/chainer/method.rb', line 11 attr_reader :context, :value |
Instance Method Details
#>>(method_name) ⇒ self
The “pipe” operator. Calls passed object
with the wrapped value
28 29 30 |
# File 'lib/chainer/method.rb', line 28 def >>(method_name) # rubocop:disable Style/OpMethod self.class.new context, context.send(method_name, value) end |