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.

Parameters:

  • value (Object)

    the input value to be typecasted.

  • opts (Hash)

    a set of options to be used when typecasting.

Returns:


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.

Returns:


32
33
34
# File 'lib/parse/model/acl.rb', line 32

def as_json(*args)
  {}.as_json
end

#attributesHash

Returns the set of attributes for this data type.

Returns:

  • (Hash)

    the set of attributes for this data type.


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

def attributes
  {}
end