Home > has_metadata_and_delegates

has_metadata_and_delegates

Has_metadata_and_delegates is a project mainly written in Ruby, based on the MIT license.

Delegates methods to a metadata association, and automatically creates it if necessary.

= Has Metadata And Delegates

Delegates methods to a metadata association, and automatically creates it if necessary.

== Example

class User < ActiveRecord::Base
    has_one :metadata, :class_name => 'UserMetadata'
    has_metadata_and_delegates :invite_count, :'foobar*'
end

class UserMetadata < ActiveRecord::Base
end

User.first.metadata_without_creation # => nil
User.first.foobar = 'blah'
User.first.metadata.foobar # => 'blah'

== Rails Versions

This plugin is known to work in versions of rails 2.x. It has not been tested in rails 3.

Please let me know what experience you have if you try this with rails 3.

Copyright (c) 2009 Amiel Martin, released under the MIT license