0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
Use dynamic attributes in your classes
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

 Project Readme

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: