Skip to content

Commit 1d9addd

Browse files
committed
cleanup - merge core_ext with base_ext + use method_defined? due 1.9
... since instance_methods returns strings on 1.8 but symbol names on 1.9
1 parent 69ce9fb commit 1d9addd

File tree

3 files changed

+35
-35
lines changed

3 files changed

+35
-35
lines changed

lib/arjdbc/jdbc/adapter.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22
require 'active_record/connection_adapters/abstract_adapter'
33

44
require 'arjdbc/version'
5+
require 'arjdbc/jdbc/java'
56
require 'arjdbc/jdbc/base_ext'
67
require 'arjdbc/jdbc/connection_methods'
7-
require 'arjdbc/jdbc/core_ext'
8-
require 'arjdbc/jdbc/java'
98
require 'arjdbc/jdbc/driver'
109
require 'arjdbc/jdbc/column'
1110
require 'arjdbc/jdbc/connection'

lib/arjdbc/jdbc/base_ext.rb

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,40 @@
11
module ActiveRecord
2-
class Base # reopen
2+
# ActiveRecord::Base extensions.
3+
Base.class_eval do
34
class << self
4-
# Allow adapters to provide their own reset_column_information methods
5-
#
6-
# NOTE: This only affects the current thread's connection.
7-
def reset_column_information_with_arjdbc_base_ext
8-
# Invoke the adapter-specific reset_column_information method
5+
# Allow adapters to provide their own {#reset_column_information} method.
6+
# @note This only affects the current thread's connection.
7+
def reset_column_information_with_arjdbc
8+
# invoke the adapter-specific reset_column_information method
99
connection.reset_column_information if connection.respond_to?(:reset_column_information)
10-
reset_column_information_without_arjdbc_base_ext
10+
reset_column_information_without_arjdbc
11+
end
12+
unless method_defined?("reset_column_information_without_arjdbc")
13+
alias_method_chain :reset_column_information, :arjdbc
14+
end
15+
end
16+
end
17+
18+
# Represents exceptions that have propagated up through the JDBC API.
19+
class JDBCError < ActiveRecordError
20+
# The vendor code or error number that came from the database
21+
attr_accessor :errno
22+
# The full Java SQLException object that was raised.
23+
attr_accessor :sql_exception
24+
end
25+
26+
module ConnectionAdapters # :nodoc:
27+
# Allows properly re-defining methods that may already be alias_method_chain'd.
28+
module ShadowCoreMethods
29+
def alias_chained_method(name, feature, target)
30+
# NOTE: aliasing for things such as columns (with feature query_cache)
31+
# seems to only be used for 2.3 since 3.0 methods are not aliased ...
32+
if method_defined?(method = "#{name}_without_#{feature}")
33+
alias_method method, target
34+
else
35+
alias_method name, target if name.to_s != target.to_s
36+
end
1137
end
12-
alias_method_chain :reset_column_information, :arjdbc_base_ext unless instance_methods.include?("reset_column_information_without_arjdbc_base_ext")
1338
end
1439
end
15-
end
40+
end

lib/arjdbc/jdbc/core_ext.rb

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)