Skip to content
This repository has been archived by the owner on Jun 26, 2019. It is now read-only.

juancolacelli/acts_as_dynamic

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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:

About

Use dynamic attributes in your classes

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages