Class: Core::Pipeline::Action
- Inherits:
-
Object
- Object
- Core::Pipeline::Action
- Includes:
- Is::Inspectable, Is::Stateful
- 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.
-
#name ⇒ Object
readonly
- public
-
The action name.
Class Method Summary collapse
-
.build(target = nil, *args, before: nil, after: nil, context: nil, &block) ⇒ Object
- public
-
Builds an action for a given target.
- .build_name ⇒ Object
- .generate_random_suffix ⇒ Object
Instance Method Summary collapse
-
#finalize(context) ⇒ Object
- public
-
Finalizes the action for the given context.
-
#initialize(name, before: nil, after: nil, context: nil) ⇒ Action
constructor
A new instance of Action.
Constructor Details
#initialize(name, before: nil, after: nil, context: nil) ⇒ Action
Returns a new instance of Action.
58 59 60 61 62 63 |
# File 'lib/core/pipeline/action.rb', line 58 def initialize(name, before: nil, after: nil, context: nil) @name = (name || self.class.build_name).to_sym @before = before @after = after @context = context end |
Instance Attribute Details
#after ⇒ Object (readonly)
- public
-
The name of the action this action should be called after.
75 76 77 |
# File 'lib/core/pipeline/action.rb', line 75 def after @after end |
#before ⇒ Object (readonly)
- public
-
The name of the action this action should be called before.
71 72 73 |
# File 'lib/core/pipeline/action.rb', line 71 def before @before end |
#name ⇒ Object (readonly)
- public
-
The action name.
67 68 69 |
# File 'lib/core/pipeline/action.rb', line 67 def name @name end |
Class Method Details
.build(target = nil, *args, before: nil, after: nil, context: nil, &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, &block) if block Actions::Block.new(target, before: before, after: after, context: context, &block) else build_target(target, *args, before: before, after: after, context: context) 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
#finalize(context) ⇒ Object
- public
-
Finalizes the action for the given context.
79 80 81 |
# File 'lib/core/pipeline/action.rb', line 79 def finalize(context) raise "not implemented" end |