Module: JsonApiServer::Serializer

Included in:
BaseSerializer, Error, Errors, ValidationErrors
Defined in:
lib/json_api_server/serializer.rb

Overview

Description

to_json serializer method. Used by the various serializers.

Instance Method Summary collapse

Instance Method Details

#as_jsonObject

Classes override.



15
16
17
# File 'lib/json_api_server/serializer.rb', line 15

def as_json
  {}
end

#serializer_optionsObject

Serializer options from JsonApiServer::Configuration#serializer_options.



10
11
12
# File 'lib/json_api_server/serializer.rb', line 10

def serializer_options
  JsonApiServer.configuration.serializer_options
end

#to_json(**options) ⇒ Object

Serializes to JSON. Serializer options default to JsonApiServer.configuration.serializer_options unless alternate are specified with the options parameter. Default options are:

escape_mode: :xss_safe,
time: :xmlschema,
mode: :compat

Parameters:



29
30
31
32
# File 'lib/json_api_server/serializer.rb', line 29

def to_json(**options)
  opts = options.empty? ? serializer_options : options
  Oj.dump(as_json, opts)
end