This gem provide the logic to extend classes and add capability of accept dynamic attributes.
Just add ActsAsDynamic in your Gemfile:
gem "acts_as_dynamic"
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| ...
ActsAsDynamic is released under the MIT license: