Class: Core::Operation::Action
- Inherits:
-
Object
- Object
- Core::Operation::Action
- Includes:
- Inspect, State
- Defined in:
- lib/core/operation/action.rb
Overview
- public
-
An operation action.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
- public
-
The action name.
-
#reference ⇒ Object
readonly
- public
-
The action reference.
Class Method Summary collapse
-
.build(target = nil, *args, &block) ⇒ Object
- public
-
Builds an action for a given target.
- .build_reference ⇒ Object
- .generate_random_suffix ⇒ Object
Instance Method Summary collapse
-
#finalize(context) ⇒ Object
- public
-
Finalizes the action for the given context.
-
#initialize(name) ⇒ Action
constructor
A new instance of Action.
Constructor Details
#initialize(name) ⇒ Action
Returns a new instance of Action.
41 42 43 44 |
# File 'lib/core/operation/action.rb', line 41 def initialize(name) @name = (name || :call).to_sym @reference = self.class.build_reference.to_sym end |
Instance Attribute Details
#name ⇒ Object (readonly)
- public
-
The action name.
48 49 50 |
# File 'lib/core/operation/action.rb', line 48 def name @name end |
#reference ⇒ Object (readonly)
- public
-
The action reference.
52 53 54 |
# File 'lib/core/operation/action.rb', line 52 def reference @reference end |
Class Method Details
.build(target = nil, *args, &block) ⇒ Object
- public
-
Builds an action for a given target.
18 19 20 21 22 |
# File 'lib/core/operation/action.rb', line 18 def build(target = nil, *args, &block) raise ArgumentError, "actions must be defined with a block" unless block Actions::Block.new(target, &block) end |
.build_reference ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/core/operation/action.rb', line 24 def build_reference suffix = generate_random_suffix if __used_random_suffixes__.include?(suffix) build_reference else __used_random_suffixes__ << suffix "action_#{suffix}" end end |
.generate_random_suffix ⇒ Object
34 35 36 |
# File 'lib/core/operation/action.rb', line 34 def generate_random_suffix SecureRandom.hex(8) end |
Instance Method Details
#finalize(context) ⇒ Object
- public
-
Finalizes the action for the given context.
56 57 58 |
# File 'lib/core/operation/action.rb', line 56 def finalize(context) raise "not implemented" end |