AR Delegation plugin

Plugin details

Be able to delegate ActiveRecord fields between objects when using belongs_to relationships.

Websitehttp://daveverwer.com/2007/3/16/activerecord-delegation Repositorysvn://rubyforge.org/var/svn/ar-delegation Author Dave Verwer Tags ActiveRecord, delegation LicenseUnknown

Documentation

Install the plugin:
ruby script/plugin install svn://rubyforge.org/var/svn/ar-delegation

Plug-in time! Wouldn’t it be nice to do something like this?

class Person < ActiveRecord::Base
  belongs_to :company
  has_columns :from => :company, :except => "id" 
end


and get a fully nil safe set of delegated methods out of it so you can just call the fields like they belong to the model doing the delegation.

Hopefully these other examples will be self explanatory as to what this little plug-in can do:

has_columns :from => :source, :except => "id" 
has_columns :from => :source, :only => [ "title", "name" ], :prefix => "src_" 
has_column :col_name, :from => :source, :as => :new_name
has_column :col_name, :from => :source


It does allow fields to be prefixed which might be useful if you are bringing in fields from multiple other models or would just like to prefix the fields.

Further Documentation

There is currently no advanced documentation for this plugin.

New documentation

Edit plugin | (0 older versions) | Last edited by: hardway, about 1 year ago