Permalink
Browse files

Changes for data_fabric on AR3.1 beta, fixes GH-11

  • Loading branch information...
1 parent 5b5a39b commit 34f51ed7beee2e3d8df9de85ce716e8490eec12c @mperham mperham committed May 12, 2011
Showing with 20 additions and 6 deletions.
  1. +17 −6 lib/data_fabric/connection_proxy.rb
  2. +3 −0 test/connection_test.rb
@@ -46,6 +46,17 @@ def connected?
end
end
end
+
+ %w(columns columns_hash table_exists? primary_keys).each do |name|
+ define_method(name.to_sym) do |*args|
+ @proxy.current_pool.send(name.to_sym, *args)
+ end
+ end
+
+ def method_missing(name, *args)
+ DataFabric.logger.warn "Add '#{name}' to DataFabric::PoolProxy for performance"
+ @proxy.current_pool.send(name, *args)
+ end
end
class ConnectionProxy
@@ -105,12 +116,6 @@ def connection
current_pool.connection
end
- private
-
- def in_transaction?
- current_role == 'master'
- end
-
def current_pool
name = connection_name
self.class.shard_pools[name] ||= begin
@@ -120,6 +125,12 @@ def current_pool
end
end
+ private
+
+ def in_transaction?
+ current_role == 'master'
+ end
+
def spec_for(config)
# XXX This looks pretty fragile. Will break if AR changes how it initializes connections and adapters.
config = config.symbolize_keys
View
@@ -37,6 +37,9 @@ def tables
def table_exists?(name)
true
end
+ def last_inserted_id(result)
+ 1
+ end
def method_missing(name, *args)
raise ArgumentError, "#{self.class.name} missing '#{name}': #{args.inspect}"
end

0 comments on commit 34f51ed

Please sign in to comment.