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.
26 27 28 |
# File 'lib/parse/model/acl.rb', line 26 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.
33 34 35 |
# File 'lib/parse/model/acl.rb', line 33 def as_json(*args) {}.as_json end |
#attributes ⇒ Hash
Returns the set of attributes for this data type.
16 17 18 |
# File 'lib/parse/model/acl.rb', line 16 def attributes {} end |