File: C:/Ruby27-x64/lib/ruby/gems/2.7.0/doc/activemodel-7.0.4.2/ri/ActiveModel/Model/cdesc-Model.ri
U:RDoc::NormalModule[iI"
Model:ETI"ActiveModel::Model;T0o:RDoc::Markup::Document:@parts[o;;[S:RDoc::Markup::Heading:
leveli: textI" Active \Model \Basic \Model;To:RDoc::Markup::BlankLine o:RDoc::Markup::Paragraph;[ I"?Allows implementing models similar to ActiveRecord::Base. ;TI"AIncludes ActiveModel::API for the required interface for an ;TI"Eobject to interact with Action Pack and Action View, but can be ;TI")extended with other functionalities.;T@o;
;[I"'A minimal implementation could be:;T@o:RDoc::Markup::Verbatim;[
I"class Person
;TI"" include ActiveModel::Model
;TI"! attr_accessor :name, :age
;TI" end
;TI"
;TI"1person = Person.new(name: 'bob', age: '18')
;TI"person.name # => "bob"
;TI"person.age # => "18"
;T:@format0o;
;[I"JIf for some reason you need to run code on <tt>initialize</tt>, make ;TI"Msure you call +super+ if you want the attributes hash initialization to ;TI"happen.;T@o;;[I"class Person
;TI"" include ActiveModel::Model
;TI"& attr_accessor :id, :name, :omg
;TI"
;TI"% def initialize(attributes={})
;TI" super
;TI" @omg ||= true
;TI" end
;TI" end
;TI"
;TI"-person = Person.new(id: 1, name: 'bob')
;TI"person.omg # => true
;T;0o;
;[I"NFor more detailed information on other functionalities available, please ;TI"Krefer to the specific modules included in <tt>ActiveModel::Model</tt> ;TI"(see below).;T:
@fileI"lib/active_model/model.rb;T:0@omit_headings_from_table_of_contents_below0;0;0[ [ [[I"ActiveModel::API;To;;[ ;@;;0I"lib/active_model/model.rb;T[[I"
class;T[[:public[ [:protected[ [:private[ [I"
instance;T[[;[ [;[ [;[ [[I"ActiveSupport::Concern;To;;[ ;@;;0@C[U:RDoc::Context::Section[i 0o;;[ ;0;0[@;I"ActiveModel;TcRDoc::NormalModule