lib/neo4j/active_node/scope.rb in neo4j-7.0.6 vs lib/neo4j/active_node/scope.rb in neo4j-7.0.7

- old
+ new

@@ -33,17 +33,17 @@ # end # Person.as(:all_people).great_students(:all_people).to_a # # @see http://guides.rubyonrails.org/active_record_querying.html#scopes def scope(name, proc) - _scope[name.to_sym] = proc + scopes[name.to_sym] = proc klass = class << self; self; end klass.instance_eval do define_method(name) do |query_params = nil, _ = nil| eval_context = ScopeEvalContext.new(self, current_scope || self.query_proxy) - proc = _scope[name.to_sym] + proc = full_scopes[name.to_sym] _call_scope_context(eval_context, query_params, proc) end end end @@ -54,14 +54,18 @@ scope?(name) end # rubocop:enable Style/PredicateName def scope?(name) - _scope.key?(name.to_sym) + full_scopes.key?(name.to_sym) end - def _scope - @_scope ||= {} + def scopes + @scopes ||= {} + end + + def full_scopes + scopes.merge(self.superclass.respond_to?(:scopes) ? self.superclass.scopes : {}) end def _call_scope_context(eval_context, query_params, proc) if proc.arity == 1 eval_context.instance_exec(query_params, &proc)