lib/cassandra_object/scope.rb in gotime-cassandra_object-4.10.1 vs lib/cassandra_object/scope.rb in gotime-cassandra_object-4.10.2
- old
+ new
@@ -16,12 +16,20 @@
@select_values = []
@where_values = []
end
private
+
+ def scoping
+ previous, klass.current_scope = klass.current_scope, self
+ yield
+ ensure
+ klass.current_scope = previous
+ end
+
def method_missing(method_name, *args, &block)
if klass.respond_to?(method_name)
- klass.send(method_name, *args, &block)
+ scoping { klass.send(method_name, *args, &block) }
elsif Array.method_defined?(method_name)
to_a.send(method_name, *args, &block)
else
super
end