No commit activity in last 3 years
No release in over 3 years
Cache nonchanging ActiveRecord models in memory
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 1.3
>= 0
~> 3.1
= 1.3.8

Runtime

~> 4.1.0
 Project Readme

CachedEnumeration

Loads your active record objects into memory so you don't have to include them.

Currently works with Rails 4.2.

Installation

Add this line to your application's Gemfile:

gem 'cached_enumeration'

And then execute:

$ bundle

Or install it yourself as:

$ gem install cached_enumeration

Usage

class Gender < ActiveRecord::Base
  cache_enumeration :order => 'name', :hashed => [:id,:name], :constantize => true

Now the following situations are cached:

  • Gender.find(1)
  • Gender.by_id(1)
  • Gender.find_by_name('male')
  • Gender.all
  • Gender::MALE
  • Gender::FEMALE

Development

docker run -it \
  --name cached_enumeration \
  --volume $PWD:/home/default/cached_enumeration \
  --workdir /home/default/cached_enumeration \
  <ruby-image>

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request