Class: Ridgepole::Diff
- Inherits:
-
Object
- Object
- Ridgepole::Diff
- Defined in:
- lib/ridgepole/diff.rb
Instance Method Summary collapse
- #diff(from, to) ⇒ Object
-
#initialize(options = {}) ⇒ Diff
constructor
A new instance of Diff.
Constructor Details
#initialize(options = {}) ⇒ Diff
Returns a new instance of Diff.
2 3 4 |
# File 'lib/ridgepole/diff.rb', line 2 def initialize( = {}) @options = end |
Instance Method Details
#diff(from, to) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/ridgepole/diff.rb', line 6 def diff(from, to) from = (from || {}).dup to = (to || {}).dup if @options[:reverse] from, to = to, from end delta = {} scan_table_rename(from, to, delta) # for reverse option scan_table_rename(to, from, delta) to.each do |table_name, to_attrs| next unless target?(table_name) if (from_attrs = from.delete(table_name)) scan_change(table_name, from_attrs, to_attrs, delta) else delta[:add] ||= {} delta[:add][table_name] = to_attrs end end unless @options[:merge] from.each do |table_name, from_attrs| next unless target?(table_name) delta[:delete] ||= {} delta[:delete][table_name] = from_attrs end end Ridgepole::Delta.new(delta, @options) end |