Class: DBA::RowCommand

Inherits:
Command show all
Defined in:
lib/dba/row_command.rb

Direct Known Subclasses

Edit, Find

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



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/dba/row_command.rb', line 2

def call(table, identifier)
  self.table_name = table

  self.table_schema = DBA::TableSchema.new(database, table_name)

  self.primary_key = table_schema.primary_key

  self.dataset = database[table_name].where(primary_key => identifier)

  self.row = dataset.first

  unless row
    raise DBA::Error, "could not find row #{primary_key}=#{identifier}"
  end
end