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
-
#as_json ⇒ Object
Classes override.
-
#serializer_options ⇒ Object
Serializer options from JsonApiServer::Configuration#serializer_options.
-
#to_json(**options) ⇒ Object
Serializes to JSON.
Instance Method Details
#as_json ⇒ Object
Classes override.
15 16 17 |
# File 'lib/json_api_server/serializer.rb', line 15 def as_json {} end |
#serializer_options ⇒ Object
Serializer options from JsonApiServer::Configuration#serializer_options.
10 11 12 |
# File 'lib/json_api_server/serializer.rb', line 10 def JsonApiServer.configuration. 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:
-
options (Hash) - OJ serialization options: github.com/ohler55/oj#options. If none specified, it uses defaults.
29 30 31 32 |
# File 'lib/json_api_server/serializer.rb', line 29 def to_json(**) opts = .empty? ? : Oj.dump(as_json, opts) end |