Module: Avm::Sources::Base::Update

Defined in:
lib/avm/sources/base/update.rb

Instance Method Summary collapse

Instance Method Details

#on_sub_updatedObject

To override in subclasses.



12
13
14
# File 'lib/avm/sources/base/update.rb', line 12

def on_sub_updated
  # Do nothing
end

#updatevoid

This method returns an undefined value.



17
18
19
20
21
# File 'lib/avm/sources/base/update.rb', line 17

def update
  update_self_before_subs
  update_subs
  update_self_after_subs
end

#update_self(changes) ⇒ void

This method returns an undefined value.

Parameters:



25
26
27
# File 'lib/avm/sources/base/update.rb', line 25

def update_self(changes)
  changes.each { |change| update_self_with_change(change) }
end

#update_self_after_subsvoid

This method returns an undefined value.



30
31
32
33
# File 'lib/avm/sources/base/update.rb', line 30

def update_self_after_subs
  infov __method__, self
  update_self(update_self_changes_after_subs)
end

#update_self_before_subsvoid

This method returns an undefined value.



36
37
38
39
# File 'lib/avm/sources/base/update.rb', line 36

def update_self_before_subs
  infov __method__, self
  update_self(update_self_changes_before_subs)
end

#update_self_changes_after_subsEnumerable<Avm::Sources::Change>

Changes for update after subs' updating.

Returns:



43
44
45
# File 'lib/avm/sources/base/update.rb', line 43

def update_self_changes_after_subs
  []
end

#update_self_changes_before_subsEnumerable<Avm::Sources::Change>

Changes for update before subs' updating.

Returns:



49
50
51
# File 'lib/avm/sources/base/update.rb', line 49

def update_self_changes_before_subs
  []
end

#update_self_with_change(change) ⇒ void

This method returns an undefined value.

Parameters:



55
56
57
58
59
60
61
# File 'lib/avm/sources/base/update.rb', line 55

def update_self_with_change(change)
  infov 'Performing change', change
  scm.commit_if_change(-> { change.commit_message }) do
    change.perform
    parent.if_present(&:on_sub_updated)
  end
end