{"id":13880012,"url":"https://github.com/zeisler/active_enumerable","last_synced_at":"2025-07-16T16:30:38.919Z","repository":{"id":62552754,"uuid":"48867339","full_name":"zeisler/active_enumerable","owner":"zeisler","description":"ActiveRecord like query methods for Ruby enumerable collections.","archived":false,"fork":false,"pushed_at":"2018-08-01T19:54:13.000Z","size":49,"stargazers_count":73,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-06-29T15:17:02.118Z","etag":null,"topics":["enumerable","hash","objects","querydsl","rails","rubygem"],"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/zeisler.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-01-01T02:09:58.000Z","updated_at":"2025-05-13T04:09:41.000Z","dependencies_parsed_at":"2022-11-03T04:15:35.860Z","dependency_job_id":null,"html_url":"https://github.com/zeisler/active_enumerable","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/zeisler/active_enumerable","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zeisler%2Factive_enumerable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zeisler%2Factive_enumerable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zeisler%2Factive_enumerable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zeisler%2Factive_enumerable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zeisler","download_url":"https://codeload.github.com/zeisler/active_enumerable/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zeisler%2Factive_enumerable/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265524602,"owners_count":23782009,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["enumerable","hash","objects","querydsl","rails","rubygem"],"created_at":"2024-08-06T08:02:43.464Z","updated_at":"2025-07-16T16:30:38.669Z","avatar_url":"https://github.com/zeisler.png","language":"Ruby","readme":"# ActiveEnumerable\n\n[![Build Status](https://travis-ci.org/zeisler/active_enumerable.svg?branch=master)](https://travis-ci.org/zeisler/active_enumerable)\n[![Gem Version](https://badge.fury.io/rb/active_enumerable.svg)](https://badge.fury.io/rb/active_enumerable)\n\nProvides ActiveRecord like query methods for use in Ruby Enumerable collections.\nUse Hashes or custom Ruby Objects to represent records. \n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'active_enumerable'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install active_enumerable\n\n## Usage\n\n[Documentation](http://www.rubydoc.info/gems/active_enumerable/1.0.0)\n\n### ActiveRecord Like Querying\n\n```ruby\nrequire \"active_enumerable\"\n\nclass Customers\n  include ActiveEnumerable\n\n  scope :unpaid, -\u003e { where(paid: false).or(credit: 0) }\nend\n\ncustomers = Customers.new([{paid: true, credit: 1000}, {paid: false, credit: 2000}, {paid: false, credit: 0}])\n\ncustomers.unpaid\n# =\u003e \u003c#Customers [{:paid=\u003efalse, :credit=\u003e2000}, {:paid=\u003efalse, :credit=\u003e0}]]\u003e\n\ncustomers.scope { select { |y| y[:credit] \u003e= 1000 } }\n#=\u003e \u003c#Customers [{paid: true, credit: 1000}, {paid: false, credit: 2000}]\u003e\n\ncustomers.sum(:credit)\n#=\u003e 3000\n\ncustomers \u003c\u003c { paid: true, credit: 1500 } # accepts Hashes\n\ncustomers.where{ paid \u0026\u0026 credit == 1000 }\n# =\u003e \u003c#Customers [{paid: true, credit: 1000}]\n\nclass Customer\n  attr_reader :paid, :credit\n  def initialize(paid:, credit:)\n    @paid  = paid\n    @credit = credit\n  end\nend\n\ncustomers \u003c\u003c Customer.new(paid: true, credit: 1500) # Or Objects\n```\n\n### English Like DSL\n\n```ruby\nrequire \"active_enumerable\"\n\nclass People\n  include ActiveEnumerable\n  \n  scope :unpaid, -\u003e { where(paid: false).or(credit: 0) }\nend\n\npeople = People.new([{ name: \"Reuben\" }, { name: \"Naomi\" }])\npeople.where { has(:name).of(\"Reuben\") }\n    #=\u003e \u003c#People [{ name: \"Reuben\" }]]\n    \n    \npeople = People.new( [\n        { name: \"Reuben\", parents: [{ name: \"Mom\", age: 29 }, { name: \"Dad\", age: 33 }] },\n        { name: \"Naomi\", parents: [{ name: \"Mom\", age: 29 }, { name: \"Dad\", age: 41 }] }\n      ] )\n      \npeople.where { has(:parents).of(age: 29, name: \"Mom\").or(age: 33, name: \"Dad\") } \n    #=\u003e  \u003c#People [{ name: \"Reuben\", parents: [...] }, { name: \"Naomi\", parents: [...] }]\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\nThis is a community project and commit access will be granted to those who show interest by having a history of acceptable pull-requests.\n\nBug reports and pull requests are welcome on GitHub at https://github.com/zeisler/active_enumerable. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.\n\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n\n","funding_links":[],"categories":["Ruby"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzeisler%2Factive_enumerable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzeisler%2Factive_enumerable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzeisler%2Factive_enumerable/lists"}