Class: DbAgile::SequelAdapter

Inherits:
Adapter
  • Object
show all
Extended by:
ClassMethods
Includes:
Connection, Data::TableDriven, Data::TransactionDriven, Schema::TableDriven, Schema::TransactionDriven
Defined in:
lib/dbagile/adapter/sequel.rb,
lib/dbagile/adapter/sequel/connection.rb,
lib/dbagile/adapter/sequel/class_methods.rb,
lib/dbagile/adapter/sequel/sequel_tracer.rb,
lib/dbagile/adapter/sequel/data/table_driven.rb,
lib/dbagile/adapter/sequel/schema/table_driven.rb,
lib/dbagile/adapter/sequel/schema/physical_dump.rb,
lib/dbagile/adapter/sequel/schema/concrete_script.rb,
lib/dbagile/adapter/sequel/data/transaction_driven.rb,
lib/dbagile/adapter/sequel/schema/schema2sequel_args.rb,
lib/dbagile/adapter/sequel/schema/transaction_driven.rb

Overview

Implements the Adapter contract using Sequel.

Defined Under Namespace

Modules: ClassMethods, Connection, Data, Schema Classes: SequelTracer

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ClassMethods

new

Methods included from Schema::TransactionDriven

#add_columns, #create_table, #drop_table, #key!, #run_schema_script

Methods included from Schema::TableDriven

#column_names, #dbtype_to_ruby_type, #has_table?, #heading, #keys

Methods included from Data::TransactionDriven

#delete, #direct_sql, #insert, #update

Methods included from Data::TableDriven

#dataset, #exists?

Methods included from Connection

#disconnect, #physical_schema, #ping, #script2sql, #transaction

Methods inherited from Adapter

[], factor

Methods included from Contract::Schema::TransactionDriven

#add_columns, #create_table, #drop_table, #key!

Methods included from Contract::Schema::TableDriven

#column_names, #has_column?, #has_table?, #heading, #is_key?, #keys

Methods included from Contract::Data::TransactionDriven

#delete, #direct_sql, #insert, #update

Methods included from Contract::Data::TableDriven

#dataset, #exists?

Methods included from Contract::Connection

#disconnect, #physical_schema, #ping, #ping?, #script2sql, #transaction

Methods included from Contract::Robust::Helpers

#has_table!, #not_has_table!

Constructor Details

#initialize(uri, options = {}) ⇒ SequelAdapter

Creates an adapter with a given uri



31
32
33
# File 'lib/dbagile/adapter/sequel.rb', line 31

def initialize(uri, options = {})
  @uri, @options = uri, options
end

Instance Attribute Details

#optionsObject (readonly)

Connection options



28
29
30
# File 'lib/dbagile/adapter/sequel.rb', line 28

def options
  @options
end

#uriObject (readonly)

Underlying database URI



25
26
27
# File 'lib/dbagile/adapter/sequel.rb', line 25

def uri
  @uri
end

Instance Method Details

#dbObject

Returns the underlying Sequel::Database instance



36
37
38
39
40
41
42
# File 'lib/dbagile/adapter/sequel.rb', line 36

def db
  unless @db
    @db = ::Sequel.connect(uri)
    @db.logger = @options[:sequel_logger]
  end
  @db
end