lib/neo4j/active_node/scope.rb in neo4j-7.2.3 vs lib/neo4j/active_node/scope.rb in neo4j-8.0.0.alpha.1

- old
+ new

@@ -62,11 +62,11 @@ def scopes @scopes ||= {} end def full_scopes - scopes.merge(self.superclass.respond_to?(:scopes) ? self.superclass.scopes : {}) + self.superclass.respond_to?(:scopes) ? self.superclass.scopes.merge(scopes) : scopes end def _call_scope_context(eval_context, query_params, proc) if proc.arity == 1 eval_context.instance_exec(query_params, &proc) @@ -98,16 +98,33 @@ def initialize(target, query_proxy) @query_proxy = query_proxy @target = target end + def identity + query_proxy_or_target.identity + end + Neo4j::ActiveNode::Query::QueryProxy::METHODS.each do |method| - module_eval(%{ - def #{method}(params={}) - @target.all.scoping do - (@query_proxy || @target).#{method}(params) - end - end}, __FILE__, __LINE__) + define_method(method) do |*args| + @target.all.scoping do + query_proxy_or_target.public_send(method, *args) + end + end + end + + def method_missing(name, *params, &block) + if query_proxy_or_target.respond_to?(name) + query_proxy_or_target.public_send(name, *params, &block) + else + super + end + end + + private + + def query_proxy_or_target + @query_proxy_or_target ||= @query_proxy || @target end end # Stolen from ActiveRecord