Class: Imparcial::Driver::AbstractAdapter

Inherits:
Object
  • Object
show all
Includes:
AbstractExpression, AbstractSQL, AbstractTypemap, AbstractUtil
Defined in:
lib/imparcial/driver/abstract.rb

Overview

You have seriously to pay attention on this class. Basically speaking, it servers as abstraction for all new drivers. The idea behind Imparcial is to keep an abstract interface without exposing any dataabstract-specific-features. Of course, it’s an impossible mission anyhow. There are so many dataabases out there and there are so many cool features that make impossible not to expose them. We recommend you to obey the interface as much as possible. However you may develop some specific features. Please, keep an eye on specification(can be found in the website).

Direct Known Subclasses

MysqlAdapter, PostgreAdapter

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from AbstractTypemap

#column_to_field, #default_size_for_types, #field_to_column, #field_to_column_sql, #parse_field, #parse_fields, #regular_types, #sql_types

Methods included from AbstractUtil

#quote, #quote_value, #unquote_value

Methods included from Imparcial::Driver::AbstractExpression::Index

#create_index, #drop_all_indexes, #drop_index, #expected_options_for_dropping_all_indexes, #get_indexes, #index_exists?

Methods included from Imparcial::Driver::AbstractExpression::Transaction

#create_savepoint, #initialize_transaction, #restore_savepoint, #rollback_transaction, #terminate_transaction

Methods included from Imparcial::Driver::AbstractExpression::Record

#total_of_records

Methods included from Imparcial::Driver::AbstractExpression::Update

#update

Methods included from Imparcial::Driver::AbstractExpression::Delete

#delete, #delete_all

Methods included from Imparcial::Driver::AbstractExpression::Select

#select

Methods included from Imparcial::Driver::AbstractExpression::Insert

#insert

Methods included from Imparcial::Driver::AbstractExpression::Constraint

#add_auto_increment, #add_default_value, #add_primary_key

Methods included from Imparcial::Driver::AbstractExpression::Table

#create_table, #diff_columns, #drop_all_tables, #drop_table, #drop_table_if_necessary, #get_tables, #report_modified_columns, #report_new_columns, #report_old_columns, #table_exists?, #table_not_exists?

Methods included from Imparcial::Driver::AbstractExpression::Column

#add_columns, #drop_columns, #get_column_information, #get_columns_information, #modify_columns, #rename_column, #rename_columns

Methods included from Imparcial::Driver::AbstractExpression::Sequence

#create_sequence, #create_sequence_if_necessary, #drop_all_sequences, #drop_sequence, #drop_sequence_if_necessary, #get_sequences, #sequence_exists?

Instance Attribute Details

#adapterObject

Returns the value of attribute adapter.



54
55
56
# File 'lib/imparcial/driver/abstract.rb', line 54

def adapter
  @adapter
end

#connObject

Description

Display connection handle.

Returning

a handle.



47
48
49
# File 'lib/imparcial/driver/abstract.rb', line 47

def conn
  @conn
end

#databaseObject

Returns the value of attribute database.



54
55
56
# File 'lib/imparcial/driver/abstract.rb', line 54

def database
  @database
end

#hostObject

Returns the value of attribute host.



54
55
56
# File 'lib/imparcial/driver/abstract.rb', line 54

def host
  @host
end

#loggerObject

A logger is also required.



52
53
54
# File 'lib/imparcial/driver/abstract.rb', line 52

def logger
  @logger
end

#passwordObject

Returns the value of attribute password.



54
55
56
# File 'lib/imparcial/driver/abstract.rb', line 54

def password
  @password
end

#portObject

Returns the value of attribute port.



54
55
56
# File 'lib/imparcial/driver/abstract.rb', line 54

def port
  @port
end

#socketObject

Returns the value of attribute socket.



54
55
56
# File 'lib/imparcial/driver/abstract.rb', line 54

def socket
  @socket
end

#usernameObject

Returns the value of attribute username.



54
55
56
# File 'lib/imparcial/driver/abstract.rb', line 54

def username
  @username
end

Instance Method Details

#adapter_specific_exceptionObject

Description

get the adapter specific’s exception.

Returning

an exception class.

Raises:



138
139
140
141
142
# File 'lib/imparcial/driver/abstract.rb', line 138

def adapter_specific_exception
  
  raise FeatureNotFound
  
end

#closeObject

Description

Terminate a connection.

Returning

nothing.



82
83
84
85
86
# File 'lib/imparcial/driver/abstract.rb', line 82

def close

  conn.close

end

#connectObject

Description

Stablish a connection.

Returning

nothing.

Raises:



114
115
116
117
118
# File 'lib/imparcial/driver/abstract.rb', line 114

def connect

  raise FeatureNotFound

end

#connectionObject

Let’s also keep a track of the connection.



48
49
50
# File 'lib/imparcial/driver/abstract.rb', line 48

def conn
  @conn
end

#disable_column_loggingObject



176
177
178
179
180
# File 'lib/imparcial/driver/abstract.rb', line 176

def disable_column_logging
  
  @column_logging = false
  
end

#disable_index_loggingObject



188
189
190
191
192
# File 'lib/imparcial/driver/abstract.rb', line 188

def disable_index_logging
  
  @index_logging = false
  
end

#disable_insert_loggingObject



224
225
226
227
228
# File 'lib/imparcial/driver/abstract.rb', line 224

def disable_insert_logging
  
  @insert_logging = false
  
end

#disable_record_loggingObject



248
249
250
251
252
# File 'lib/imparcial/driver/abstract.rb', line 248

def disable_record_logging
  
  @record_logging = false
  
end

#disable_select_loggingObject



200
201
202
203
204
# File 'lib/imparcial/driver/abstract.rb', line 200

def disable_select_logging
  
  @select_logging = false
  
end

#disable_sequence_loggingObject



236
237
238
239
240
# File 'lib/imparcial/driver/abstract.rb', line 236

def disable_sequence_logging
  
  @sequence_logging = false
  
end

#disable_table_loggingObject



164
165
166
167
168
# File 'lib/imparcial/driver/abstract.rb', line 164

def disable_table_logging
  
  @table_logging = false
  
end

#disable_update_loggingObject



212
213
214
215
216
# File 'lib/imparcial/driver/abstract.rb', line 212

def disable_update_logging
  
  @update_logging = false
  
end

#enable_column_loggingObject



170
171
172
173
174
# File 'lib/imparcial/driver/abstract.rb', line 170

def enable_column_logging
  
  @column_logging = true
  
end

#enable_index_loggingObject



182
183
184
185
186
# File 'lib/imparcial/driver/abstract.rb', line 182

def enable_index_logging
  
  @index_logging = true
  
end

#enable_insert_loggingObject



218
219
220
221
222
# File 'lib/imparcial/driver/abstract.rb', line 218

def enable_insert_logging
  
  @insert_logging = true
  
end

#enable_record_loggingObject



242
243
244
245
246
# File 'lib/imparcial/driver/abstract.rb', line 242

def enable_record_logging
  
  @record_logging = true
  
end

#enable_select_loggingObject



194
195
196
197
198
# File 'lib/imparcial/driver/abstract.rb', line 194

def enable_select_logging
  
  @select_logging = true
  
end

#enable_sequence_loggingObject



230
231
232
233
234
# File 'lib/imparcial/driver/abstract.rb', line 230

def enable_sequence_logging
  
  @sequence_logging = true
  
end

#enable_table_loggingObject

#

Logging mechanism                  #
                                   #


158
159
160
161
162
# File 'lib/imparcial/driver/abstract.rb', line 158

def enable_table_logging
  
  @table_logging = true
  
end

#enable_update_loggingObject



206
207
208
209
210
# File 'lib/imparcial/driver/abstract.rb', line 206

def enable_update_logging
  
  @update_logging = true
  
end

#last_insert_idObject

Raises:



144
145
146
147
148
# File 'lib/imparcial/driver/abstract.rb', line 144

def last_insert_id
  
  raise FeatureNotFound
  
end

#query(sql) ⇒ Object

Description

Execute a statement directly to the adapter.

Returning

The method result will be avaliable.

Raises:



126
127
128
129
130
# File 'lib/imparcial/driver/abstract.rb', line 126

def query ( sql )
      
  raise FeatureNotFound

end

#resultObject

Description

After executing a statement, the method query will bring a result.

Returning

result to a query.

Raises:



94
95
96
97
98
99
# File 'lib/imparcial/driver/abstract.rb', line 94

def result

  raise ResultError.new('Have you made any query?') unless @result
  @result

end