Class: DbDiff::Row

Inherits:
TableElement show all
Defined in:
lib/dbdiff/row.rb

Instance Attribute Summary collapse

Attributes inherited from TableElement

#name, #table_name

Instance Method Summary collapse

Methods inherited from TableElement

#deep_clone

Constructor Details

#initialize(table, info = {}) ⇒ Row

Returns a new instance of Row.



8
9
10
11
12
13
# File 'lib/dbdiff/row.rb', line 8

def initialize(table, info = {})
  @data = info.dup  
  @primary_key = table.primary_key
  @name = @primary_key.map {|k|@data[k] }.join("|") # XXX fix this to be more unique of a name
  @table_name = table.name
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



6
7
8
# File 'lib/dbdiff/row.rb', line 6

def data
  @data
end

#primary_keyObject (readonly)

Returns the value of attribute primary_key.



6
7
8
# File 'lib/dbdiff/row.rb', line 6

def primary_key
  @primary_key
end

Instance Method Details

#==(other) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/dbdiff/row.rb', line 28

def ==(other)
  other_data = other.data.dup
  source_data = self.data.dup

  %w(created_on updated_on).each do|c|
    other_data.delete(c)
    source_data.delete(c)
  end

  source_data == other_data
end

#add_deltaObject



16
17
18
# File 'lib/dbdiff/row.rb', line 16

def add_delta
  Delta::AddRow.new(self)
end

#drop_deltaObject



24
25
26
# File 'lib/dbdiff/row.rb', line 24

def drop_delta
  Delta::DropRow.new(self)
end

#modify_delta(new_element) ⇒ Object



20
21
22
# File 'lib/dbdiff/row.rb', line 20

def modify_delta(new_element)
  Delta::ModifyRow.new(new_element)
end