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
-
.in_memory_adapter_path ⇒ String
The path used to require the in memory adapter.
-
.in_memory_adapter_path=(path) ⇒ Object
The path used to require the in memory adapter.
-
.new(repository_name, options) ⇒ Object
private
Set up an adapter for a storage engine.
Methods included from Chainable
Methods included from Assertions
Class Method Details
.in_memory_adapter_path ⇒ String
The path used to require the in memory adapter
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
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
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, ) = () case .fetch(:adapter) when 'java' # discover the real adapter jndi_uri = "#{[:scheme]}:#{[:path]}" context = javax.naming.InitialContext.new ds= context.lookup(jndi_uri) conn = ds.getConnection begin = conn.getMetaData 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 [:adapter] = driver ensure conn.close end else driver = .fetch(:adapter) end # case adapter_class(driver).new(repository_name, ) end |