Class: Core::Pipeline::Action
- Inherits:
-
Object
- Object
- Core::Pipeline::Action
- Includes:
- Inspect, State
- Defined in:
- lib/core/pipeline/action.rb
Overview
[public] A pipeline action.
Direct Known Subclasses
Core::Pipeline::Actions::Block, Core::Pipeline::Actions::Method
Instance Attribute Summary collapse
-
#after ⇒ Object
readonly
[public] The name of the action this action should be called after.
-
#before ⇒ Object
readonly
[public] The name of the action this action should be called before.
-
#context ⇒ Object
readonly
[public] The context this action should be called in.
-
#name ⇒ Object
readonly
[public] The action name.
Class Method Summary collapse
-
.build(target = nil, *args, before: nil, after: nil, context: nil, curry: false, &block) ⇒ Object
[public] Builds an action for a given target.
- .build_name ⇒ Object
- .generate_random_suffix ⇒ Object
Instance Method Summary collapse
-
#curried? ⇒ Boolean
[public] Returns
trueif the action should be curried. -
#finalize(context) ⇒ Object
[public] Finalizes the action for the given context.
-
#initialize(name, before: nil, after: nil, context: nil, curry: false) ⇒ Action
constructor
A new instance of Action.
Constructor Details
#initialize(name, before: nil, after: nil, context: nil, curry: false) ⇒ Action
Returns a new instance of Action.
58 59 60 61 62 63 64 |
# File 'lib/core/pipeline/action.rb', line 58 def initialize(name, before: nil, after: nil, context: nil, curry: false) @name = (name || self.class.build_name).to_sym @before = before @after = after @context = context @curry = curry end |
Instance Attribute Details
#after ⇒ Object (readonly)
[public] The name of the action this action should be called after.
76 77 78 |
# File 'lib/core/pipeline/action.rb', line 76 def after @after end |
#before ⇒ Object (readonly)
[public] The name of the action this action should be called before.
72 73 74 |
# File 'lib/core/pipeline/action.rb', line 72 def before @before end |
#context ⇒ Object (readonly)
[public] The context this action should be called in.
80 81 82 |
# File 'lib/core/pipeline/action.rb', line 80 def context @context end |
#name ⇒ Object (readonly)
[public] The action name.
68 69 70 |
# File 'lib/core/pipeline/action.rb', line 68 def name @name end |
Class Method Details
.build(target = nil, *args, before: nil, after: nil, context: nil, curry: false, &block) ⇒ Object
[public] Builds an action for a given target.
18 19 20 21 22 23 24 |
# File 'lib/core/pipeline/action.rb', line 18 def build(target = nil, *args, before: nil, after: nil, context: nil, curry: false, &block) if block Actions::Block.new(target, before: before, after: after, context: context, curry: curry, &block) else build_target(target, *args, before: before, after: after, context: context, curry: curry) end end |
.build_name ⇒ Object
41 42 43 44 45 46 47 48 49 |
# File 'lib/core/pipeline/action.rb', line 41 def build_name suffix = generate_random_suffix if __used_random_suffixes__.include?(suffix) build_name else __used_random_suffixes__ << suffix "action_#{suffix}" end end |
.generate_random_suffix ⇒ Object
51 52 53 |
# File 'lib/core/pipeline/action.rb', line 51 def generate_random_suffix SecureRandom.hex(8) end |
Instance Method Details
#curried? ⇒ Boolean
[public] Returns true if the action should be curried.
84 85 86 |
# File 'lib/core/pipeline/action.rb', line 84 def curried? @curry == true end |
#finalize(context) ⇒ Object
[public] Finalizes the action for the given context.
90 91 92 |
# File 'lib/core/pipeline/action.rb', line 90 def finalize(context) raise "not implemented" end |