Class: Core::Pipeline::Actions::Block
- Inherits:
-
Core::Pipeline::Action
- Object
- Core::Pipeline::Action
- Core::Pipeline::Actions::Block
- Includes:
- Inspect
- Defined in:
- lib/core/pipeline/actions/block.rb
Overview
[public] A pipeline action defined as a block.
Instance Attribute Summary
Attributes inherited from Core::Pipeline::Action
#after, #before, #context, #name
Instance Method Summary collapse
-
#finalize(context) ⇒ Object
[public].
-
#initialize(name = nil, before: nil, after: nil, context: nil, curry: false, &block) ⇒ Block
constructor
A new instance of Block.
Methods inherited from Core::Pipeline::Action
build, build_name, #curried?, generate_random_suffix
Constructor Details
#initialize(name = nil, before: nil, after: nil, context: nil, curry: false, &block) ⇒ Block
Returns a new instance of Block.
13 14 15 16 17 |
# File 'lib/core/pipeline/actions/block.rb', line 13 def initialize(name = nil, before: nil, after: nil, context: nil, curry: false, &block) @block = block super(name, before: before, after: after, context: context, curry: curry) end |
Instance Method Details
#finalize(context) ⇒ Object
[public]
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/core/pipeline/actions/block.rb', line 21 def finalize(context) case @context when NilClass unless context.method_defined?(@name) context.define_method(@name, &@block) end @name else if @block.binding.receiver.equal?(@context) @block else unless context.singleton_class.method_defined?(@name) @context.define_singleton_method(@name, &@block) end @context.method(@name).to_proc end end end |