Class Index [+]

Quicksearch

DataMapper::Spec::Adapters::Adapter

Attributes

name[R]

Public Class Methods

new(name) click to toggle source
    # File lib/dm-core/spec/setup.rb, line 95
95:         def initialize(name)
96:           @name = name.to_sym
97:         end

Public Instance Methods

adapter() click to toggle source
     # File lib/dm-core/spec/setup.rb, line 99
 99:         def adapter
100:           @adapter ||= setup!
101:         end
Also aliased as: setup
adapter_name() click to toggle source
     # File lib/dm-core/spec/setup.rb, line 113
113:         def adapter_name
114:           @adapter_name ||= infer_adapter_name
115:         end
alternate_storage_name() click to toggle source
     # File lib/dm-core/spec/setup.rb, line 129
129:         def alternate_storage_name
130:           "datamapper_alternate_tests"
131:         end
connection_uri() click to toggle source
     # File lib/dm-core/spec/setup.rb, line 117
117:         def connection_uri
118:           "#{adapter_name}://#{username}:#{password}@#{host}/#{storage_name}"
119:         end
default_storage_name() click to toggle source
     # File lib/dm-core/spec/setup.rb, line 125
125:         def default_storage_name
126:           "datamapper_default_tests"
127:         end
host() click to toggle source
     # File lib/dm-core/spec/setup.rb, line 141
141:         def host
142:           ENV.fetch('DM_DB_HOST', 'localhost')
143:         end
password() click to toggle source
     # File lib/dm-core/spec/setup.rb, line 137
137:         def password
138:           ENV.fetch('DM_DB_PASSWORD', 'datamapper')
139:         end
setup() click to toggle source
Alias for: adapter
setup!() click to toggle source
     # File lib/dm-core/spec/setup.rb, line 105
105:         def setup!
106:           adapter = DataMapper.setup(name, connection_uri)
107:           test_connection(adapter)
108:           adapter
109:         rescue Exception => e
110:           puts "Could not connect to the database using '#{connection_uri}' because of: #{e.inspect}"
111:         end
storage_name() click to toggle source
     # File lib/dm-core/spec/setup.rb, line 121
121:         def storage_name
122:           send("#{name}_storage_name")
123:         end
test_connection(adapter) click to toggle source

Test the connection

Overwrite this method if you need to perform custom connection testing

@raise [Exception]

     # File lib/dm-core/spec/setup.rb, line 150
150:         def test_connection(adapter)
151:           if adapter.respond_to?(:select)
152:             adapter.select('SELECT 1')
153:           end
154:         end
username() click to toggle source
     # File lib/dm-core/spec/setup.rb, line 133
133:         def username
134:           ENV.fetch('DM_DB_USER', 'datamapper')
135:         end

Private Instance Methods

infer_adapter_name() click to toggle source
     # File lib/dm-core/spec/setup.rb, line 158
158:         def infer_adapter_name
159:           demodulized = DataMapper::Inflector.demodulize(self.class.name.chomp('Adapter'))
160:           DataMapper::Inflector.underscore(demodulized).freeze
161:         end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.