by Jason L Perry (paint.itred.org)
A replacement for ActiveRecord when you just need to model a few unchanging objects, and don't necessarily need a full blown ActiveRecord class and table in the database. Use with reservation.
some basic ActiveRecord style finders
dynamic attribute based finders, supporting basic comparisons as well regular expressions and ranges
some integrated ActiveRecord associactions, ie: ActiveRecord#belongs_to(:passive_record) PassiveRecord#has_many(:active_records) (excluding has_many :through)
extend find options like :conditions, :order
find(:first) (depends on :order being implemented)
better documentation of the code
fix warnings in tests
class Continent < PassiveRecord::Base has_many :countries # => an ActiveRecord class schema :name => String, :size => Integer, :population => Integer create :name => "Africa", :size => 30370000, :population => 890000000 create :name => "Antarctica", :size => 13720000, :population => 1000 create :name => "Australia", :size => 7600000, :population => 20000000 create :name => "Eurasia", :size => 53990000, :population => 4510000000 create :name => "North America", :size => 24490000, :population => 515000000 create :name => "South America", :size => 17840000, :population => 371000000 end Continent.find(1) # => Africa Continent.find_by_name("Africa") # => Yes, also Africa Continent.find_by_name_and_size(/America/, 17840000) # => South America Continent.find_all_by_population(1000..20000000) # => Antarctica and Australia Continent.find(:all) # => All 6 (though not in any particular order, yet)
gem install passiverecord
(The MIT License)
Copyright © 2007 Jason L Perry (Paint.itRed)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.