Class: Cocina::Instance

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/cocina/instance.rb,
lib/cocina/instance/action.rb

Defined Under Namespace

Classes: Action

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#dependenciesObject (readonly)

Returns the value of attribute dependencies.



8
9
10
# File 'lib/cocina/instance.rb', line 8

def dependencies
  @dependencies
end

#nameObject (readonly)

Returns the value of attribute name.



8
9
10
# File 'lib/cocina/instance.rb', line 8

def name
  @name
end

#runnerObject

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

Returns:

  • (Boolean)


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_actionsObject

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