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

See Also:

Returns:

  • the path used to require the desired in memory adapter

API:

  • semipublic



66
67
68
# File 'lib/dm-core/adapters.rb', line 66

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

See Also:

Parameters:

  • the path used to require the desired in memory adapter

API:

  • semipublic



54
55
56
# File 'lib/dm-core/adapters.rb', line 54

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:

API:

  • private



10
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
# File 'lib/dm-core/adapters.rb', line 10

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'
               end
      options[:adapter] = driver
    ensure
      conn.close
    end
  else
    driver = options.fetch(:adapter)
  end

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