GitXplorerGitXplorer
n

model_set

public
7 stars
4 forks
1 issues

Commits

List of commits on branch master.
Unverified
b5e3e6eec8af7e4b41b916fb4708f40599312189

Merge pull request #7 from ss/master

nninjudd committed 11 years ago
Unverified
707a93d58c7424e3945a11222f759e217061a07b

Ruby 2.0 encoding fixes.

sscott-steadman committed 11 years ago
Unverified
bdbc7194659d0e1eed4dfb7ba0d3ceeca7d07206

1.1.2

nninjudd committed 11 years ago
Unverified
716131661954dafaa38314fcf78f9b230126e7cb

remove system_timer dependency

nninjudd committed 11 years ago
Unverified
634d5a45c21841f17b406d4d8c08bd17a16ca653

add license

nninjudd committed 12 years ago
Unverified
7a4cd5543e811909f6f63786c4a32f723859e8a5

1.1.1

nninjudd committed 12 years ago

README

The README file for this repository.

= 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 (c) 2009 Justin Balthrop, Geni.com; Published under The MIT License, see LICENSE