Project

view_model

0.0
No commit activity in last 3 years
No release in over 3 years
Rails compatible view models
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.8
~> 10.0

Runtime

~> 1.0
 Project Readme

ViewModel

Travis Gem Version Code Climate Test Coverage Inline docs

Gem | Source | Documentation

Rails compatible view models ignoring persistence. Just a wrapper around the gems 'virtus' and 'activemodel'.

https://github.com/solnic/virtus https://github.com/rails/rails/tree/master/activemodel

Installation

Add this line to your application's Gemfile:

gem 'view_model'

And then execute:

$ bundle

Usage

class Profile < ViewModel::Base
  attribute :name, String
  validates :name, :presence => true
end
  
vm = Profile.new({:name => 'Bob'})

vm.valid? # => true
vm.attributes # => {:name => 'Bob'}