From c73275721327fd3ef53ed35514eb204718da6ede Mon Sep 17 00:00:00 2001 From: ryoya-kobayashi Date: Tue, 2 Jun 2026 00:26:24 +0900 Subject: [PATCH] Remove duplicate definitions causing method-redefined warnings (#1434) Three methods were defined twice in the same class, causing Ruby to emit 'method redefined; discarding old ...' warnings whenever the gem is required with warnings enabled. The first definition in each pair was dead code: it was shadowed by a later, real implementation. * `Ransack::Nodes::Condition#arel_predicate` was defined as a stub raising "not implemented" and re-defined further down with the actual implementation. * `Ransack::Nodes::Grouping#conditions` had an `attr_reader` that was immediately shadowed by an explicit `def` doing lazy init. * `Ransack::Context#arel_visitor` was listed in two consecutive `attr_reader` calls. Dropping the dead definitions removes the warnings without any behavioural change (the live implementations were already the ones in effect). --- lib/ransack/context.rb | 1 - lib/ransack/nodes/condition.rb | 4 ---- lib/ransack/nodes/grouping.rb | 1 - 3 files changed, 6 deletions(-) diff --git a/lib/ransack/context.rb b/lib/ransack/context.rb index d04c69eb..c007a412 100644 --- a/lib/ransack/context.rb +++ b/lib/ransack/context.rb @@ -4,7 +4,6 @@ module Ransack class Context attr_reader :search, :object, :klass, :base, :engine, :arel_visitor attr_accessor :auth_object, :search_key - attr_reader :arel_visitor class << self diff --git a/lib/ransack/nodes/condition.rb b/lib/ransack/nodes/condition.rb index 0b024fdc..dcf4b56c 100644 --- a/lib/ransack/nodes/condition.rb +++ b/lib/ransack/nodes/condition.rb @@ -217,10 +217,6 @@ def predicate_name end alias :p :predicate_name - def arel_predicate - raise "not implemented" - end - def validated_values values.select { |v| predicate.validator.call(v.value) } end diff --git a/lib/ransack/nodes/grouping.rb b/lib/ransack/nodes/grouping.rb index 20f3ff65..1a7ee631 100644 --- a/lib/ransack/nodes/grouping.rb +++ b/lib/ransack/nodes/grouping.rb @@ -1,7 +1,6 @@ module Ransack module Nodes class Grouping < Node - attr_reader :conditions attr_accessor :combinator alias :m :combinator alias :m= :combinator=