Module: Fie::Changelog

Included in:
State
Defined in:
lib/fie/state/changelog.rb

Instance Method Summary collapse

Instance Method Details

#update_object_using_changelog(changelog, object = self) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/fie/state/changelog.rb', line 3

def update_object_using_changelog(changelog, object = self)
  unless changelog.blank?
    changelog.each do |node_name, _|
      changelog_node = changelog[node_name]
      is_not_end_of_tree = changelog_node.is_a? Hash

      if is_not_end_of_tree
        traverse \
          changelog: changelog,
          object: object,
          node_name: node_name,
          changelog_node: changelog_node
      else
        update_object_value \
          object: object,
          node_name: node_name,
          value: changelog_node
      end
    end
  end
end