Provides a data structure for collecting homogeneous objects and indexing them for quick lookup.
Ruby 2.3+
Add this line to your application's Gemfile:
gem 'active_registry'
And then execute:
$ bundle
Or install it yourself as:
$ gem install active_registry
Person = Struct.new(:id, :name, :email)
registry = ActiveRegistry.new([
Person.new(1, 'Dale', 'jason@twilightcoders.net'),
Person.new(2, 'Dale', 'dale@twilightcoders.net')
])
registry.index(:name)
d = registry[:name, 'Dale'].first
d.name = "Jason"
registry.find(:name, 'Jason')
After checking out the repo, run bundle
to install dependencies. Then, run bundle exec rspec
to run the tests.
Bug reports and pull requests are welcome on GitHub at https://github.com/TwilightCoders/active_registry. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
The gem is available as open source under the terms of the MIT License.