{"id":13878447,"url":"https://github.com/samuelgiles/sorbet-struct-comparable","last_synced_at":"2026-01-19T04:00:56.158Z","repository":{"id":43065653,"uuid":"272627225","full_name":"samuelgiles/sorbet-struct-comparable","owner":"samuelgiles","description":"Comparable T::Struct's for the equality focused typed Ruby developer.","archived":false,"fork":false,"pushed_at":"2023-04-10T07:11:24.000Z","size":368,"stargazers_count":34,"open_issues_count":0,"forks_count":5,"subscribers_count":4,"default_branch":"master","last_synced_at":"2026-01-14T00:56:06.315Z","etag":null,"topics":["compare","comparison","equality","equals","ruby","sorbet","struct","structs","type-safety","typed","types"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/samuelgiles.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2020-06-16T06:26:28.000Z","updated_at":"2025-10-05T13:08:16.000Z","dependencies_parsed_at":"2023-07-13T19:49:12.255Z","dependency_job_id":null,"html_url":"https://github.com/samuelgiles/sorbet-struct-comparable","commit_stats":null,"previous_names":["bellroy/sorbet-struct-comparable","tricycle/sorbet-struct-comparable"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/samuelgiles/sorbet-struct-comparable","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samuelgiles%2Fsorbet-struct-comparable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samuelgiles%2Fsorbet-struct-comparable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samuelgiles%2Fsorbet-struct-comparable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samuelgiles%2Fsorbet-struct-comparable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/samuelgiles","download_url":"https://codeload.github.com/samuelgiles/sorbet-struct-comparable/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samuelgiles%2Fsorbet-struct-comparable/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28561596,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-19T03:31:16.861Z","status":"ssl_error","status_checked_at":"2026-01-19T03:31:15.069Z","response_time":67,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["compare","comparison","equality","equals","ruby","sorbet","struct","structs","type-safety","typed","types"],"created_at":"2024-08-06T08:01:50.080Z","updated_at":"2026-01-19T04:00:56.126Z","avatar_url":"https://github.com/samuelgiles.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"![Sorbet](https://user-images.githubusercontent.com/2643026/84757714-60be0600-afbc-11ea-8c0e-7da839ea1712.png)\n\n[![Gem Version](https://badge.fury.io/rb/sorbet-struct-comparable.svg)](https://badge.fury.io/rb/sorbet-struct-comparable) ![Continuous Integration](https://github.com/samuelgiles/sorbet-struct-comparable/workflows/Continuous%20Integration/badge.svg)\n# Making T::Struct's comparable since 2020\n\nIf you just want some simple equality checking on your `T::Struct`'s then you've come to the right place.\n\nOut of the box Sorbet's super useful `T::Struct`'s (\u003chttps://sorbet.org/docs/tstruct\u003e) are not comparable meaning two separate instances (i.e. different `#object_id`'s) of a `T::Struct` with identical attributes are not equal.\n\nThis behaviour can be confusing at first glance, especially if/when you start using `T::Struct`'s alongside RSpec where expectations such as `it { is_expected.to eq my_expected_struct }` will fail.\n\nIt makes sense for this comparable behaviour to not be baked into `T::Struct`'s by default since defining what makes two instances of something equal could be seen by some as business logic, but for the 90% of cases where you just want to run `\u003c=\u003e` over your attributes this mixin is a solution.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'sorbet-struct-comparable'\n```\n\nAnd then execute:\n\n    $ bundle install\n\nOr install it yourself as:\n\n    $ gem install sorbet-struct-comparable\n\n## Usage\n\nJust include `T::Struct::ActsAsComparable` in your struct, done!\n\n```ruby\nrequire 'sorbet-struct-comparable'\n\nclass BlogPost \u003c T::Struct\n  include T::Struct::ActsAsComparable\n\n  class Topic \u003c T::Enum\n    enums do\n      Cycling = new\n      Music = new\n      Walking = new\n    end\n  end\n\n  const :title, String\n  const :topic, Topic\nend\n\nblog_post = BlogPost.new(title: 'My Blog Post', topic: BlogPost::Topic::Cycling)\ndifferent_blog_post = BlogPost.new(title: 'Another Blog Post', topic: BlogPost::Topic::Walking)\nidentical_blog_post = BlogPost.new(title: 'My Blog Post', topic: BlogPost::Topic::Cycling)\n\nblog_post == different_blog_post\n# =\u003e false\nblog_post == identical_blog_post\n# =\u003e true\n```\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/samuelgiles/sorbet-struct-comparable.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamuelgiles%2Fsorbet-struct-comparable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsamuelgiles%2Fsorbet-struct-comparable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamuelgiles%2Fsorbet-struct-comparable/lists"}