Sha256: 11dd28fd90a3a82b00e7d2b7b3b50612b4feb5091a33fe236d6f417599f49afb

Contents?: true

Size: 414 Bytes

Versions: 9

Compression:

Stored size: 414 Bytes

Contents

module DuckPuncher
  class UniqueDuck < DelegateClass(Duck)
    attr_accessor :punch_options

    #
    # Required to play nice in a Set
    #

    def eql?(other)
      "#{target}-#{mod}" == "#{other.target}-#{other.mod}"
    end

    def hash
      target.to_s.hash + mod.to_s.hash + punch_options.to_s.hash
    end

    #
    # Sorting
    #

    def <=>(other)
      target <=> other.target
    end

  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
duck_puncher-5.0.1 lib/duck_puncher/unique_duck.rb
duck_puncher-5.0.0 lib/duck_puncher/unique_duck.rb
duck_puncher-4.5.1 lib/duck_puncher/unique_duck.rb
duck_puncher-4.5.0 lib/duck_puncher/unique_duck.rb
duck_puncher-4.4.2 lib/duck_puncher/unique_duck.rb
duck_puncher-4.4.1 lib/duck_puncher/unique_duck.rb
duck_puncher-4.4.0 lib/duck_puncher/unique_duck.rb
duck_puncher-4.3.1 lib/duck_puncher/unique_duck.rb
duck_puncher-4.3.0 lib/duck_puncher/unique_duck.rb