Class: Dry::Core::Equalizer

Inherits:
Module
  • Object
show all
Defined in:
lib/dry/core/equalizer.rb

Overview

Define equality, equivalence and inspection methods

Defined Under Namespace

Modules: Methods

Instance Method Summary collapse

Constructor Details

#initialize(*keys, **options) ⇒ undefined

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Initialize an Equalizer with the given keys

Will use the keys with which it is initialized to define #cmp?, #hash, and #inspect

Parameters:

  • keys (Array<Symbol>)
  • options (Hash)

Options Hash (**options):

  • :inspect (Boolean)

    whether to define #inspect method

  • :immutable (Boolean)

    whether to memoize #hash method



20
21
22
23
24
25
# File 'lib/dry/core/equalizer.rb', line 20

def initialize(*keys, **options)
  super()
  @keys = keys.uniq
  define_methods(**options)
  freeze
end