Skip to content

Commit

Permalink
push duplicates? logic to the instance
Browse files Browse the repository at this point in the history
  • Loading branch information
tenderlove committed May 10, 2013
1 parent c5ed42a commit 17dfee0
Showing 1 changed file with 7 additions and 16 deletions.
23 changes: 7 additions & 16 deletions activesupport/lib/active_support/callbacks.rb
Expand Up @@ -94,20 +94,8 @@ module Filters
end

class Callback #:nodoc:#
class Unduplicable < Callback # :nodoc:
def duplicates?(other)
false
end
end

def self.build(chain, filter, kind, options, _klass)
klass = case filter
when Symbol, String
Callback
else
Callback::Unduplicable
end
klass.new chain, filter, kind, options, _klass
new chain, filter, kind, options, _klass
end

attr_accessor :chain, :kind, :options, :klass, :raw_filter
Expand Down Expand Up @@ -155,9 +143,12 @@ def matches?(_kind, _filter)
end

def duplicates?(other)
return false unless self.class == other.class

matches?(other.kind, other.filter)
case @raw_filter
when Symbol, String
matches?(other.kind, other.filter)
else
false
end
end

def _update_filter(filter_options, new_options)
Expand Down

0 comments on commit 17dfee0

Please sign in to comment.