class DBA::RowCommand

Attributes

dataset[RW]
primary_key[R]
row[RW]
table_schema[RW]

Public Instance Methods

call(table, identifier) click to toggle source
# 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

Private Instance Methods

primary_key=(primary_key) click to toggle source
# File lib/dba/row_command.rb, line 24
def primary_key=(primary_key)
  unless primary_key
    raise DBA::Error, "could not find primary key for #{table_name} table"
  end

  @primary_key = primary_key
end