acts_as_dynamic

Use dynamic attributes in your classes


License
MIT
Install
gem install acts_as_dynamic -v 0.0.5

Documentation

ActsAsDynamic

This gem provide the logic to extend classes and add capability of accept dynamic attributes.

Installation

Just add ActsAsDynamic in your Gemfile:

gem "acts_as_dynamic"

Method of use

You can set dynamic attributes using builder:

class User
  acts_as_dynamic

  validates_presence_of :name

  def complete_name
    [self.name, self.last_name].join " "
  end
end

person = Person.new(:name => "Chuck", :last_name => "Norris")
person.complete_name
#=> "Chuck Norris"

Or using method dynamic attributes directly:

person.age = 18
person.age
#=> 18

And you can use ActiveModel methods:

person.valid?
#=> true

Or use the instance at a Ruby on Rails form:

= form_for person do |f|
  ...

License

ActsAsDynamic is released under the MIT license: