Sha256: 62a4b02618d3352408cf3cbc0db2984e8a85b1190aadd09e540107b12963492f
Contents?: true
Size: 546 Bytes
Versions: 6
Compression:
Stored size: 546 Bytes
Contents
require 'active_model' class UserForm include ActiveModel::Model include ActiveModel::Validations attr_accessor :name, :email, :id validates :name, :email, presence: true def initialize(params = {}) @id = params[:id] @name = params[:name] @email = params[:email] end def to_h { name: name, email: email } end def merge(input) @name = input[:name] @email = input[:email] self end def persisted? id.present? end def self.model_name ActiveModel::Name.new(User) end end
Version data entries
6 entries across 6 versions & 1 rubygems