Class: Cocina::Instance
- Inherits:
-
Object
- Object
- Cocina::Instance
- Extended by:
- Forwardable
- Defined in:
- lib/cocina/instance.rb,
lib/cocina/instance/action.rb
Defined Under Namespace
Classes: Action
Instance Attribute Summary collapse
-
#actions(*list) ⇒ Object
readonly
Set or return the list of actions.
-
#dependencies ⇒ Object
readonly
Returns the value of attribute dependencies.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#runner ⇒ Object
Returns the value of attribute runner.
Instance Method Summary collapse
-
#dependencies? ⇒ Boolean
Check if the Instance has any defined dependencies.
-
#depends(dep) ⇒ Object
Define a dependency for the Instance.
-
#initialize(name) ⇒ Instance
constructor
A new instance of Instance.
-
#run_actions ⇒ Object
Run all actions defined for the Instance.
Constructor Details
#initialize(name) ⇒ Instance
Returns a new instance of Instance.
13 14 15 16 17 |
# File 'lib/cocina/instance.rb', line 13 def initialize(name) @name = name @dependencies = [] @actions = default_actions end |
Instance Attribute Details
#actions(*list) ⇒ Object (readonly)
Set or return the list of actions
33 34 35 |
# File 'lib/cocina/instance.rb', line 33 def actions @actions end |
#dependencies ⇒ Object (readonly)
Returns the value of attribute dependencies.
8 9 10 |
# File 'lib/cocina/instance.rb', line 8 def dependencies @dependencies end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/cocina/instance.rb', line 8 def name @name end |
#runner ⇒ Object
Returns the value of attribute runner.
9 10 11 |
# File 'lib/cocina/instance.rb', line 9 def runner @runner end |
Instance Method Details
#dependencies? ⇒ Boolean
Check if the Instance has any defined dependencies
27 28 29 |
# File 'lib/cocina/instance.rb', line 27 def dependencies? dependencies.empty? ? false : true end |
#depends(dep) ⇒ Object
Define a dependency for the Instance
21 22 23 |
# File 'lib/cocina/instance.rb', line 21 def depends(dep) @dependencies << dep end |
#run_actions ⇒ Object
Run all actions defined for the Instance
46 47 48 49 50 51 |
# File 'lib/cocina/instance.rb', line 46 def run_actions actions.each do |action| # execute perform.before send action end end |