Module: DataMapper::Adapters

Extended by:
Assertions, Chainable
Defined in:
lib/dm-core/adapters.rb,
lib/dm-core/adapters/abstract_adapter.rb,
lib/dm-core/adapters/in_memory_adapter.rb

Defined Under Namespace

Classes: AbstractAdapter, InMemoryAdapter

Class Method Summary collapse

Methods included from Chainable

chainable, extendable

Methods included from Assertions

assert_kind_of

Class Method Details

.in_memory_adapter_pathString

The path used to require the in memory adapter

Returns:

  • (String)

    the path used to require the desired in memory adapter

See Also:


69
70
71
# File 'lib/dm-core/adapters.rb', line 69

def self.in_memory_adapter_path
  @in_memory_adapter_path ||= 'dm-core/adapters/in_memory_adapter'
end

.in_memory_adapter_path=(path) ⇒ Object

The path used to require the in memory adapter

Set this if you want to register your own adapter to be used when you specify an 'in_memory' connection during

Parameters:

  • path (String)

    the path used to require the desired in memory adapter

See Also:


57
58
59
# File 'lib/dm-core/adapters.rb', line 57

def self.in_memory_adapter_path=(path)
  @in_memory_adapter_path = path
end

.new(repository_name, options) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Set up an adapter for a storage engine

See Also:


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/dm-core/adapters.rb', line 11

def self.new(repository_name, options)
  options = normalize_options(options)

  case options.fetch(:adapter)
  when 'java'      
    # discover the real adapter
    jndi_uri = "#{options[:scheme]}:#{options[:path]}"
    context = javax.naming.InitialContext.new 
    ds= context.lookup(jndi_uri)
    conn = ds.getConnection
    begin
       = conn.
      driver_name = .getDriverName

      driver = case driver_name
        when /mysql/i  then 'mysql'
        when /oracle/i then 'oracle'
        when /postgres/i then 'postgres'
        when /sqlite/i then 'sqlite'
        when /sqlserver|tds|Microsoft SQL/i then 'sqlserver'
        else
          nil # not supported
        end # case
        options[:adapter] = driver
    ensure
      conn.close
    end
  else
    driver = options.fetch(:adapter)
  end # case 

  adapter_class(driver).new(repository_name, options)
end