Skip to content

Commit

Permalink
add eql? and hash methods
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszreszke committed Aug 6, 2024
1 parent 4070fc9 commit 5834490
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions ecommerce/ordering/lib/ordering/order.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,5 +143,15 @@ def transition_to(state)
raise InvalidState unless ALLOWED_TRANSITIONS[@state].include?(state)
State.new(state)
end

def eql?(other)
other.instance_of?(State) && other.state.equal?(@state)
end

def hash
State.hash ^ @state.hash
end

alias == eql?
end
end

0 comments on commit 5834490

Please sign in to comment.