module Rome::Serialization
Direct including types
Defined in:
serialization.crConstructors
-
.new(pull : JSON::PullParser) : self
Initializes a record from a JSON parser.
Instance Method Summary
-
#attributes=(pull : JSON::PullParser) : Nil
Sets many attributes at once from a JSON parser.
-
#to_json(io : IO, indent = nil) : Nil
Exports the record as JSON, including all attributes and the extra attributes loaded from the database.
-
#to_json(builder : JSON::Builder) : JSON::Builder
Exports the record as JSON, including all attributes and the extra attributes loaded from the database.
-
#to_json(indent = nil) : String
Exports the record as JSON, including all attributes and the extra attributes loaded from the database.
Constructor Detail
Initializes a record from a JSON parser. This considers the record to be
a new record and not persisted. See #attributes=(JSON::PullParser)
to
update a persisted record.
user = User.new(JSON::PullParser(string_or_io))
Instance Method Detail
Sets many attributes at once from a JSON parser. For example:
user = User.find(1)
user.attributes = JSON::PullParser.new(string_or_io)
Exports the record as JSON, including all attributes and the extra attributes loaded from the database.
Exports the record as JSON, including all attributes and the extra attributes loaded from the database.
Exports the record as JSON, including all attributes and the extra attributes loaded from the database.