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
# File 'lib/avm/sources/base/update.rb', line 30

def update_self_after_subs
  update_self(update_self_changes_after_subs)
end

#update_self_before_subsvoid

This method returns an undefined value.



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

def update_self_before_subs
  update_self(update_self_changes_before_subs)
end

#update_self_changes_after_subsEnumerable<Avm::Sources::Change>

Changes for update after subs' updating.

Returns:



41
42
43
# File 'lib/avm/sources/base/update.rb', line 41

def update_self_changes_after_subs
  []
end

#update_self_changes_before_subsEnumerable<Avm::Sources::Change>

Changes for update before subs' updating.

Returns:



47
48
49
# File 'lib/avm/sources/base/update.rb', line 47

def update_self_changes_before_subs
  []
end

#update_self_with_change(change) ⇒ void

This method returns an undefined value.

Parameters:



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

def update_self_with_change(change)
  infov "Change[#{change.class}]", change.source
  scm.commit_if_change(-> { change.commit_message }) do
    change.perform
    parent.if_present(&:on_sub_updated)
  end
end