All notable changes to this project will be documented in this file.
- Breaking change: All casting errors raise
ArgumentError
. Previously some errors during casting would raiseRuntimeError
. Thanks to @gotascii for the report.
- New feature: default values. Allows you to specify a default value like so:
class User
attribute :name, :string, default: 'Michelle'
end
User.new.name
# => 'Michelle'
- Breaking change: Rename to
ModelAttribute
(no trailing 's') to avoid name clash with another gem.
-
New method: #changes_for_json Returns a hash from attribute name to its new value, suitable for serialization to a JSON string. Easily generate the payload to send in an HTTP PUT to a web service.
-
New attribute type: json Store an array/hash/etc. built using the basic JSON data types: nil, numeric, string, boolean, hash and array.
- Breaking change: Parsing an integer to a time attribute, the integer is
treated as the number of milliseconds since the epoch (not the number of
seconds).
attributes_as_json
emits integers for time attributes.
- Breaking change:
attributes_as_json
removed; replaced withattributes_for_json
. You will have to serialize this yourself:Oj.dump(attributes_for_json, mode: :strict)
. This allows you to modify the returned hash before serializing it.
- Initial release