Module: Aequitas::Equalizable

Included in:
ContextualRuleSet, Rule, Rule::Guard, Rule::SkipCondition, RuleSet, Violation
Defined in:
lib/aequitas/support/equalizable.rb

Overview

TODO: rename ValueObject (?)

Defined Under Namespace

Classes: Equalizer

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#equalizerObject (readonly)

An Equalizer module which defines #inspect, #eql?, #== and #hash for instances of this class



9
10
11
# File 'lib/aequitas/support/equalizable.rb', line 9

def equalizer
  @equalizer
end

Instance Method Details

#equalize_on(*keys) ⇒ self

Define and include a module that provides Value Object semantics for

this class. Included module will have #inspect, #eql?, #== and #hash
methods whose definition is based on the _keys_ argument

Parameters:

  • keys (Array(Symbol))

    List of keys that will be used to define #inspect, #eql?, #==, and #hash

Returns:

  • (self)


21
22
23
24
25
26
27
# File 'lib/aequitas/support/equalizable.rb', line 21

def equalize_on(*keys)
  @equalizer = Equalizer.new(keys)
  @equalizer.compile
  include @equalizer

  self
end