Class: DBMapping::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/data/sqlite/base_mapper.rb

Overview

This class serves as a parent class for the mapper classes to store common methods and attributes

Direct Known Subclasses

PersonMapper, RelationsMapper, TaskMapper

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(database) ⇒ Base

initialization

Parameters:

  • database (SQLite3::Database)

    a reference of the database



9
10
11
# File 'lib/data/sqlite/base_mapper.rb', line 9

def initialize(database)
  @db_base = SqliteDatabase::DBBasic.new(database)
end

Instance Attribute Details

#db_baseDBBasic (readonly, private)

Returns the basic database adapter.

Returns:

  • (DBBasic)

    the basic database adapter



16
17
18
# File 'lib/data/sqlite/base_mapper.rb', line 16

def db_base
  @db_base
end

Instance Method Details

#check_max_id(result) ⇒ Object (private)

helper method to determine the maximam id of the given database table

Parameters:

  • result (ResultSet | nil)

    the query result with the given max id



20
21
22
23
24
25
26
# File 'lib/data/sqlite/base_mapper.rb', line 20

def check_max_id(result)
  if (result != nil)
    Integer(result["Id"])
  else
    0
  end
end