Class: Parse::DataType
- Inherits:
- Object
- Object
- Parse::DataType
- Includes:
- ActiveModel::Model, ActiveModel::Serializers::JSON
- Defined in:
- lib/parse/model/acl.rb
Overview
This class allows you to define custom data types for your model fields. You can define a subclass that implements the DataType.typecast method to convert to and from a value for serialization. The ACL class is implemented in this fashion.
Direct Known Subclasses
Class Method Summary collapse
- .typecast(value, **opts) ⇒ Object
Transform an incoming value to another.
Instance Method Summary collapse
- #as_json(*args) ⇒ Hash
Serialize this DataType into an JSON object hash format to be saved to Parse.
- #attributes ⇒ Hash
The set of attributes for this data type.
Class Method Details
.typecast(value, **opts) ⇒ Object
Transform an incoming value to another. The default implementation does returns the original value. This method should return an instance of a DataType subclass.
25 26 27 | # File 'lib/parse/model/acl.rb', line 25 def self.typecast(value, **opts) value end |
Instance Method Details
#as_json(*args) ⇒ Hash
Serialize this DataType into an JSON object hash format to be saved to Parse. The default implementation returns an empty hash.
32 33 34 | # File 'lib/parse/model/acl.rb', line 32 def as_json(*args) {}.as_json end |
#attributes ⇒ Hash
Returns the set of attributes for this data type.
15 16 17 | # File 'lib/parse/model/acl.rb', line 15 def attributes {} end |