Method: ActiveRecord::Core#encode_with
- Defined in:
- lib/active_record/core.rb
#encode_with(coder) ⇒ Object
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, ... }}
426 427 428 429 430 |
# File 'lib/active_record/core.rb', line 426 def encode_with(coder) self.class.yaml_encoder.encode(@attributes, coder) coder["new_record"] = new_record? coder["active_record_yaml_version"] = 2 end |