Skip to content

chrisharper/fake_model

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

# README

fake_model allows you to replicate a non persisted ActiveRecord model
with validations. This is useful for cases where you want validations but
do not need persistance. 

# Usage
    class Person
      include FakeModel
      fake :name , :age
      validates :name , :presence => true
      validates :age  , :presence => true
    end

    james = Person.new :name => 'James' , :age => 40
    james.valid? # true
    Person.fake_attributes # [:name , :age]
    james.attributes # {:name => 'James' , :age => 40}
    james.age = 50 # true
    james.age # 50


All validations included in ActiveRecord are available.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages