Class: DBA::Edit

Inherits:
RowCommand show all
Defined in:
lib/dba/edit.rb

Instance Attribute Summary

Attributes inherited from Command

#database, #table_name

Instance Method Summary collapse

Methods inherited from Command

arity_check, #initialize

Constructor Details

This class inherits a constructor from DBA::Command

Instance Method Details

#call(table, identifier) ⇒ Object



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

def call(table, identifier)
  super

  row_parser = DBA::RowParser.new(table_schema)

  row_editor = DBA::RowEditor.new(row_parser)

  attributes = row_editor.edit(row)

  attributes.each do |key, value|
    attributes.delete(key) if equal?(value, row[key])
  end

  return if attributes.empty?

  database.loggers << Logger.new(STDOUT)

  dataset.update(attributes)
end