-
Notifications
You must be signed in to change notification settings - Fork 545
Add equality operator to ShipmentEvent and TrackingResponse #372
Conversation
518b209
to
3fdd841
Compare
|
||
def ==(other) | ||
name == other.name && time == other.time && location == other.location && message == other.message && | ||
type_code == other.type_code |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given the number of things you're comparing, I'd prefer it if we separated them by lines, i.e.
name == other.name &&
time == other.time &&
location == other.location &&
...
Alternatively, you could iterate over all of them, like:
attributes = [:name, :time, :location, :message, :type_code]
attributes.all? { |attr| self.public_send(:attr) == other.public_send(:attr) }
Changed how distinct |
@@ -13,5 +13,10 @@ def delivered? | |||
def status | |||
@status ||= name.downcase.gsub("\s", "_").to_sym | |||
end | |||
|
|||
def ==(other) | |||
attributes = %i(name time location message type_code) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👏 👏 👏 👏
🔴 tests aren't your fault, remote APIs are being flaky. Merge when 💚 eventually. |
…t equality, refactored how attributes are compared for equality
36822a4
to
7502694
Compare
LGTM 🚀 |
added equality operator to ShipmentEvent and TrackingResponse
added equality operator to ShipmentEvent and TrackingResponse
added equality operator to ShipmentEvent and TrackingResponse
Useful for writing tests to compare
ShipmentEvent
andTrackingResponse
objects and future use cases.cc: @jonathankwok @MalazAlamir