jankubr / hyperactiveresource forked from lukegalea/hyperactiveresource

HyperActiveResource extends ActiveResource so it works properly and behaves more like ActiveRecord

This URL has Read+Write access

name age message
file MIT-LICENSE Mon Jul 21 11:09:39 -0700 2008 first commit [lukegalea]
file README Sun Jul 27 07:03:34 -0700 2008 Added version number to readme [Luke Galea]
file Rakefile Mon Jul 21 11:09:39 -0700 2008 first commit [lukegalea]
file init.rb Mon Jul 21 11:09:39 -0700 2008 first commit [lukegalea]
file install.rb Mon Jul 21 11:09:39 -0700 2008 first commit [lukegalea]
directory lib/ Loading commit data...
directory spec/ Mon Oct 06 01:28:07 -0700 2008 Added new_record? method that only calls new? (... [Jan Kubr]
directory tasks/ Tue Jul 22 10:31:04 -0700 2008 Minor formatting changes. Small change to `rak... [nicholas a. evans]
file uninstall.rb Mon Jul 21 11:09:39 -0700 2008 first commit [lukegalea]
README
HyperactiveResource
===================

v0.1

Many have said that ActiveResource is not really "complete". On the surface,
this means that some features that are documented aren't implemented. Digging a
little deeper, we find that some features that should exist don't.

Arguably, a "complete" ActiveResource would behave like ActiveRecord or, as the
rdoc for ActiveResource states "very similarly to Active Record".

Hyperactive Resource is MDL's extension to ActiveResource::Base written to
support our Patient Registry and goes a long way towards the goal of an
ActiveResource that behaves like ActiveRecord.

Features
 * Client side validations
 * Hooks for before_validate, before_save
 * Dynamic finders: find_by_X
 * save!
 * Awareness of associations between resources: belongs_to, has_many, has_one & columns
   * Patient.new.name returns nil instead of MethodMissing
   * Patient.new.races returns [] instead of MethodMissing
   * pat = Patient.new; pat.gender_id = 1; pat.gender #Will return find the gender obj
 * Resources can be associated with records
 * Records can be associated with records
 * ActiveRecord-like attributes= (updates rather than replaces)
 * ActiveRecord-like #load that doesn't #dup attributes (stores direct reference)
 * Supports saving resources that :include other resources via:
   * Nested resource saving (creating a patient will create their associated addresses)
   * Mapping associations ([:gender].id will serialize as :gender_id)

Example
=======

 1. Install the plugin via:

    cd path/to/rails_root/vendor/plugins
    git clone git://github.com/lukegalea/hyperactiveresource.git

 2. Create a HyperactiveResource where you would normally use ActiveResource
    and define the meta-data/associations that drive the dynamic magic:

    class Address < HyperactiveResource
      self.columns = [ :street_address, :city, :zipcode, :home_phone_number ]
      self.belong_tos = [ :country, :state ]
      self.has_manys = [ :people ]
    end

 3. Enjoy the magic

    address = Address.new
    address.country # nil instead of method_missing
    address.country_id = 5
    address.country #Returns Country.find(5)
  etc..

Copyright (c) 2008 Medical Decision Logic, released under the MIT license