Class: Vcs4sql::Sqlite::Applied

Inherits:
Object
  • Object
show all
Defined in:
lib/vcs4sql/sqlite/applied.rb

Overview

The applied (existing) database change log.

Instance Method Summary collapse

Constructor Details

#initialize(conn, sql: "select * from changelog order by version") ⇒ Applied

Returns a new instance of Applied.

Parameters:

  • conn (Object)

    the connection to the database.

  • sql (String (frozen)) (defaults to: "select * from changelog order by version")

    the query to fetch the change log from db.



31
32
33
34
# File 'lib/vcs4sql/sqlite/applied.rb', line 31

def initialize(conn, sql: "select * from changelog order by version")
  @conn = conn
  @sql = sql
end

Instance Method Details

#absent(version) ⇒ Object

Ensure that applied change set has a change with particular version



41
42
43
# File 'lib/vcs4sql/sqlite/applied.rb', line 41

def absent(version)
  change(version).nil?
end

#change(version) ⇒ Object

TODO:

#/DEV Add verification of array usage over index. The changelog shouldn’t be a null.

Returns the details about applied change by version

Parameters:

  • version (Object)

    the version of applied change



49
50
51
# File 'lib/vcs4sql/sqlite/applied.rb', line 49

def change(version)
  changelog[version]
end

#empty?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/vcs4sql/sqlite/applied.rb', line 36

def empty?
  changelog.empty?
end