instance method
encode_with
Ruby on Rails 4.2.9
Since v4.0.13Signature
encode_with(coder)
Populate coder with attributes about this record that should be serialized. The structure of coder defined in this method is guaranteed to match the structure of coder passed to the init_with method.
Example:
class Post < ActiveRecord::Base end coder = {} Post.new.encode_with(coder) coder # => {"attributes" => {"id" => nil, ... }}
Parameters
-
coderreq
Source
# File activerecord/lib/active_record/core.rb, line 371
def encode_with(coder)
# FIXME: Remove this when we better serialize attributes
coder['raw_attributes'] = attributes_before_type_cast
coder['attributes'] = @attributes
coder['new_record'] = new_record?
coder['active_record_yaml_version'] = 0
end
Defined in activerecord/lib/active_record/core.rb line 371
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::Core