Project

ph_model

0.0
Low commit activity in last 3 years
A long-lived project that still receives updates
Because why do less if you can do more with non db models
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

 Project Readme

ph_model

Description

Build Status Code Climate Issue Count Dependency Status Gem Version

This Gem basically marries ActiveModel and ActiveAttr is a nice package.

The general format for this is that you make classes mixing in PhModel, and then you can use them easier as data objects.

Eg:

class MyModel
  include PhModel
  
  attribute :name, type: String
  attribute :age, type: Fixnum
  
  validates :name, presence: true
  validates :age, presence: true
end

And then .. you're meant to build these things via .build to ensure that they're valid when constructed.

Eg:

model = MyModel.build(name: "John", age: 21)

And if you were to try to construct it invalid, you'd get:

model = MyModel.build(name: "John")
# Raises: PhModel::ValidationFailed: MyModel is invalid: Age can't be blank

Copyright

Copyright (c) 2015 PayrollHero