Class: Linkage::ResultSets::Database
- Inherits:
-
Linkage::ResultSet
- Object
- Linkage::ResultSet
- Linkage::ResultSets::Database
- Includes:
- Helpers::Database
- Defined in:
- lib/linkage/result_sets/database.rb
Overview
ResultSets::Database is the ResultSet for writing to database tables. You can use it by either referencing it directly like so:
result_set = Linkage::ResultSets::Database.new(, )
Or by using ResultSet.[]:
result_set = Linkage::ResultSet['database'].new(, )
You can setup a database connection in a few different ways. By default, a
SQLite database with the filename of results.db
will be created in the
current working directory. If you want something different, you can either
specify a Sequel-style URI, provide connection options for
Sequel.connect
, or you can just specify a
Sequel::Database
object to use.
There are a couple of non-Sequel connection options:
:filename
- specify filename to use for a SQLite database:dir
- specify the parent directory for a SQLite database
This result set creates a database-backed score set
and a database-backed match set with their default
table names (scores
and matches
respectively. If either table already
exists, an ExistsError will be raised unless you set the :overwrite
option to a truthy value in the second options hash.
Constant Summary collapse
- DEFAULT_OPTIONS =
{ :filename => 'results.db' }
Instance Method Summary collapse
-
#initialize(connection_options = {}, options = {}) ⇒ Database
constructor
A new instance of Database.
- #match_set ⇒ Object
- #score_set ⇒ Object
Methods included from Helpers::Database
Methods inherited from Linkage::ResultSet
Constructor Details
#initialize(connection_options = {}, options = {}) ⇒ Database
Returns a new instance of Database.
44 45 46 47 |
# File 'lib/linkage/result_sets/database.rb', line 44 def initialize( = {}, = {}) @database = database_connection(, DEFAULT_OPTIONS) @options = end |
Instance Method Details
#match_set ⇒ Object
53 54 55 |
# File 'lib/linkage/result_sets/database.rb', line 53 def match_set @match_set ||= MatchSet['database'].new(@database, @options) end |
#score_set ⇒ Object
49 50 51 |
# File 'lib/linkage/result_sets/database.rb', line 49 def score_set @score_set ||= ScoreSet['database'].new(@database, @options) end |