Module: BlockParty::Configuration::Comparison

Included in:
BlockParty::Configuration
Defined in:
lib/block_party/configuration/comparison.rb

Instance Method Summary collapse

Instance Method Details

#==(other) ⇒ Object

Compare values only, class doesn’t matter



9
10
11
12
13
# File 'lib/block_party/configuration/comparison.rb', line 9

def == other
  if other.respond_to?(:to_hash)
    to_hash == other.to_hash
  end
end

#===(other) ⇒ Object

Compare classes or instances for case statements



23
24
25
26
27
28
29
# File 'lib/block_party/configuration/comparison.rb', line 23

def === other
  unless other.is_a? Class
    to_hash(false) == other.to_hash if other.respond_to? :to_hash
  else
    super
  end
end

#eql?(other) ⇒ Boolean

Compare values only, class matters

Returns:

  • (Boolean)


16
17
18
19
20
# File 'lib/block_party/configuration/comparison.rb', line 16

def eql?(other)
  if other.respond_to?(:to_hash)
    as_hash == other.to_hash
  end
end