Class: Parse::DataType

Inherits:
Object
  • Object
show all
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

ACL

Class Method Summary collapse

Instance Method Summary collapse

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

#attributesHash



16
17
18
# File 'lib/parse/model/acl.rb', line 16

def attributes
  {}
end