lib/replicat/replicable.rb in replicat-0.0.1 vs lib/replicat/replicable.rb in replicat-0.0.2
- old
+ new
@@ -42,13 +42,17 @@
def replications
configuration["replications"]
end
def using(connection_name)
- proxy.current_connection_name = connection_name
- yield
+ if block_given?
+ proxy.current_connection_name = connection_name
+ yield
+ else
+ ScopeProxy.new(klass: self, connection_name: connection_name)
+ end
ensure
- proxy.current_connection_name = nil
+ proxy.current_connection_name = nil if block_given?
end
end
end
end