Sha256: f366e844064baa2b6a0253f29342b0fbb9b1fa05a3cc3e261a1b4be98e1fcbc8

Contents?: true

Size: 1.58 KB

Versions: 17

Compression:

Stored size: 1.58 KB

Contents

gem "assistance", ">= 0.1"

require "metaid"
require "assistance"
require "bigdecimal"
require "bigdecimal/util"

files = %w[
  core_ext core_sql array_keys exceptions pretty_table
  dataset migration model schema database worker
]
dir = File.join(File.dirname(__FILE__), "sequel_core")
files.each {|f| require(File.join(dir, f))}

module Sequel #:nodoc:
  class << self
    # call-seq:
    #   Sequel::Database.connect(conn_string)
    #   Sequel.connect(conn_string)
    #   Sequel.open(conn_string)
    #
    # Creates a new database object based on the supplied connection string.
    # The specified scheme determines the database class used, and the rest
    # of the string specifies the connection options. For example:
    #   DB = Sequel.open 'sqlite:///blog.db'
    def connect(*args)
      Database.connect(*args)
    end
    alias_method :open, :connect
    
    def single_threaded=(value)
      Database.single_threaded = value
    end
    
    def method_missing(m, *args)
      c = Database.adapter_class(m)
      begin
        # three ways to invoke this:
        # 0 arguments: Sequel.dbi 
        # 1 argument:  Sequel.dbi(db_name)
        # more args:   Sequel.dbi(db_name, opts)
        case args.size
        when 0
          opts = {}
        when 1
          opts = args[0].is_a?(Hash) ? args[0] : {:database => args[0]}
        else
          opts = args[1].merge(:database => args[0])
        end
      rescue
        raise Error::AdapterNotFound, "Unknown adapter (#{m})"
      end
      c.new(opts)
    end
  end
end

class Object
  def Sequel(*args)
    Sequel.connect(*args)
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
sequel_core-1.0.3 lib/sequel_core.rb
sequel_core-1.0.10 lib/sequel_core.rb
sequel_core-1.0.2 lib/sequel_core.rb
sequel_core-1.0.4.1 lib/sequel_core.rb
sequel_core-1.0.8.2 lib/sequel_core.rb
sequel_core-1.0.7 lib/sequel_core.rb
sequel_core-1.0.6 lib/sequel_core.rb
sequel_core-1.0.4 lib/sequel_core.rb
sequel_core-1.0.8.1 lib/sequel_core.rb
sequel_core-1.0.5 lib/sequel_core.rb
sequel_core-1.0.9.1 lib/sequel_core.rb
sequel_core-1.0.8 lib/sequel_core.rb
sequel_core-1.2.1 lib/sequel_core.rb
sequel_core-1.1 lib/sequel_core.rb
sequel_core-1.3 lib/sequel_core.rb
sequel_core-1.4.0 lib/sequel_core.rb
sequel_core-1.2 lib/sequel_core.rb