Skip to content

Commit

Permalink
Merge pull request #2 from kim/master
Browse files Browse the repository at this point in the history
New patch release needed
  • Loading branch information
tcurdt committed Jun 22, 2011
2 parents 36d360b + b9b7ccc commit 8f61c71
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.1
0.1.2
25 changes: 21 additions & 4 deletions lib/master_slave_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,23 @@ def execute(*args)
:to => :master_connection
delegate *ActiveRecord::ConnectionAdapters::SchemaStatements.instance_methods,
:to => :master_connection
# silly: :tables is commented in SchemaStatements.
delegate :tables, :to => :master_connection
# monkey patch from databasecleaner gem
delegate :truncate_table, :to => :master_connection
# no clear interface contract:
delegate :tables, # commented in SchemaStatements
:truncate_table, # monkeypatching database_cleaner gem
:primary_key, # is Base#primary_key meant to be the contract?
:to => :master_connection
# ok, we might have missed more
def method_missing(name, *args, &blk)
master_connection.send(name.to_sym, *args, &blk).tap do
warn %Q{
You called the unsupported method '#{name}' on #{self.class.name}.
In order to help us improve master_slave_adapter, please report this
to: https://github.com/soundcloud/master_slave_adapter/issues
Thank you.
}
end
end

# === determine read connection
delegate :select_all,
Expand Down Expand Up @@ -351,6 +364,10 @@ def info(msg)
logger.try(:info, msg)
end

def warn(msg)
logger.try(:warn, msg)
end

def debug(msg)
logger.debug(msg) if logger && logger.debug?
end
Expand Down

0 comments on commit 8f61c71

Please sign in to comment.