Project

model_set

0.01
No commit activity in last 3 years
No release in over 3 years
Easy manipulation of sets of ActiveRecord models
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

~> 2.3.9
>= 1.0.1
 Project Readme

ModelSet¶ ↑

ModelSet is a array-like class for dealing with sets of ActiveRecord models. ModelSet stores a list of ids and fetches the models lazily only when necessary. You can also add conditions in SQL to further limit the set. Currently I support alternate queries using the Solr search engine through a subclass, but I plan to abstract this out into a “query engine” class that will support SQL, Solr, Sphinx, and eventually, other query methods (possibly raw RecordCache hashes and other search engines).

Usage:¶ ↑

class RobotSet < ModelSet
end

set1 = RobotSet.new([1,2,3,4]) # doesn't fetch the models

set1.each do |model| # fetches all
  # do something
end

set2 = RobotSet.new([1,2])

set3 = set1 - set2
set3.ids
# => [3,4]

set3 << Robot.find(5)
set3.ids
# => [3,4,5]

Install:¶ ↑

sudo gem install ninjudd-deep_clonable -s http://gems.github.com
sudo gem install ninjudd-ordered_set -s http://gems.github.com
sudo gem install ninjudd-model_set -s http://gems.github.com

License:¶ ↑

Copyright © 2009 Justin Balthrop, Geni.com; Published under The MIT License, see LICENSE