Module: ActiveRecord::Marshalling::Methods
| Relationships & Source Files | |
| Extension / Inclusion / Inheritance Descendants | |
|
Included In:
| |
| Defined in: | activerecord/lib/active_record/marshalling.rb |
Instance Method Summary
- #_marshal_dump_7_1 (also: #marshal_dump)
-
#marshal_dump
Alias for #_marshal_dump_7_1.
-
#marshal_load(state)
: (Array) -> void.
Instance Method Details
#_marshal_dump_7_1 Also known as: #marshal_dump
[ GitHub ]# File 'activerecord/lib/active_record/marshalling.rb', line 22
def _marshal_dump_7_1 payload = [attributes_for_database, new_record?] cached_associations = self.class.reflect_on_all_associations.select do |reflection| if association_cached?(reflection.name) association = association(reflection.name) association.loaded? || association.target.present? end end unless cached_associations.empty? payload << cached_associations.map do |reflection| [reflection.name, association(reflection.name).target] end end payload end
#marshal_dump
Alias for #_marshal_dump_7_1.
# File 'activerecord/lib/active_record/marshalling.rb', line 40
alias_method :marshal_dump, :_marshal_dump_7_1
#marshal_load(state)
: (Array) -> void
# File 'activerecord/lib/active_record/marshalling.rb', line 43
def marshal_load(state) attributes_from_database, new_record, associations = state builder = self.class.attributes_builder attributes = builder.build_from_indexed_row(builder.row_from_hash(attributes_from_database)) init_with_attributes(attributes, new_record) if associations associations.each do |name, target| association(name).target = target rescue ActiveRecord::AssociationNotFoundError # the association no longer exist, we can just skip it. end end end