HEX
Server: Apache
System: Windows NT MAGNETO-ARM 10.0 build 22000 (Windows 10) AMD64
User: Michel (0)
PHP: 7.4.7
Disabled: NONE
Upload Files
File: C:/Ruby27-x64/lib/ruby/gems/2.7.0/doc/activemodel-7.0.4.2/ri/ActiveModel/API/cdesc-API.ri
U:RDoc::NormalModule[iI"API:ETI"ActiveModel::API;T0o:RDoc::Markup::Document:@parts[o;;[S:RDoc::Markup::Heading:
leveli:	textI"Active \Model \API;To:RDoc::Markup::BlankLineo:RDoc::Markup::Paragraph;[
I"DIncludes the required interface for an object to interact with ;TI"HAction Pack and Action View, using different Active Model modules. ;TI"KIt includes model name introspections, conversions, translations, and ;TI"Nvalidations. Besides that, it allows you to initialize the object with a ;TI"=hash of attributes, pretty much like Active Record does.;T@o;
;[I"'A minimal implementation could be:;T@o:RDoc::Markup::Verbatim;[
I"class Person
;TI"   include ActiveModel::API
;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"UNote that, by default, <tt>ActiveModel::API</tt> implements <tt>persisted?</tt> ;TI"Pto return +false+, which is the most common case. You may want to override ;TI"7it in your class to simulate a different scenario:;T@o;;[I"class Person
;TI"   include ActiveModel::API
;TI"   attr_accessor :id, :name
;TI"
;TI"  def persisted?
;TI"    self.id.present?
;TI"  end
;TI"	end
;TI"
;TI"-person = Person.new(id: 1, name: 'bob')
;TI"!person.persisted? # => true
;T;0o;
;[I"PAlso, if 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::API
;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"Irefer to the specific modules included in <tt>ActiveModel::API</tt> ;TI"(see below).;T:
@fileI"lib/active_model/api.rb;T:0@omit_headings_from_table_of_contents_below0;0;0[[[[I"%ActiveModel::AttributeAssignment;To;;[;@N;0I"lib/active_model/api.rb;T[I"ActiveModel::Validations;To;;[;@N;0@V[I"ActiveModel::Conversion;To;;[;@N;0@V[[I"
class;T[[:public[[I"new;T@V[:protected[[:private[[I"
instance;T[[;[[I"persisted?;T@V[;[[;[[[I"ActiveSupport::Concern;To;;[;@N;0@V[I"ActiveModel::Naming;To;;[;@N;0@V[I"ActiveModel::Translation;To;;[;@N;0@V[U:RDoc::Context::Section[i0o;;[;0;0[@NI"ActiveModel;TcRDoc::NormalModule