Class: RESTFramework::Serializers::BaseSerializer
- Inherits:
-
Object
- Object
- RESTFramework::Serializers::BaseSerializer
- Defined in:
- lib/rest_framework/serializers/base_serializer.rb
Overview
The base serializer defines the interface for all REST Framework serializers.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#object ⇒ Object
Add
objectaccessor to be compatible withActiveModel::Serializer.
Class Method Summary collapse
-
.cache_enabled? ⇒ Boolean
For compatibility with
active_model_serializers. -
.fragment_cache_enabled? ⇒ Boolean
For compatibility with
active_model_serializers.
Instance Method Summary collapse
-
#associations(*args, **kwargs) ⇒ Object
For compatibility with
active_model_serializers. -
#initialize(object = nil, *args, controller: nil, **kwargs) ⇒ BaseSerializer
constructor
Accept/ignore ‘*args` to be compatible with the `ActiveModel::Serializer#initialize` signature.
-
#serializable_hash(*args) ⇒ Object
Synonym for
serializefor compatibility withactive_model_serializers. -
#serialize(*args) ⇒ Object
The primary interface for extracting a native Ruby types.
Constructor Details
#initialize(object = nil, *args, controller: nil, **kwargs) ⇒ BaseSerializer
Accept/ignore ‘*args` to be compatible with the `ActiveModel::Serializer#initialize` signature.
7 8 9 10 |
# File 'lib/rest_framework/serializers/base_serializer.rb', line 7 def initialize(object = nil, *args, controller: nil, **kwargs) @object = object @controller = controller end |
Instance Attribute Details
#object ⇒ Object
Add object accessor to be compatible with ActiveModel::Serializer.
4 5 6 |
# File 'lib/rest_framework/serializers/base_serializer.rb', line 4 def object @object end |
Class Method Details
.cache_enabled? ⇒ Boolean
For compatibility with active_model_serializers.
25 26 27 |
# File 'lib/rest_framework/serializers/base_serializer.rb', line 25 def self.cache_enabled? false end |
.fragment_cache_enabled? ⇒ Boolean
For compatibility with active_model_serializers.
30 31 32 |
# File 'lib/rest_framework/serializers/base_serializer.rb', line 30 def self.fragment_cache_enabled? false end |
Instance Method Details
#associations(*args, **kwargs) ⇒ Object
For compatibility with active_model_serializers.
35 36 37 |
# File 'lib/rest_framework/serializers/base_serializer.rb', line 35 def associations(*args, **kwargs) [] end |
#serializable_hash(*args) ⇒ Object
Synonym for serialize for compatibility with active_model_serializers. :nocov:
20 21 22 |
# File 'lib/rest_framework/serializers/base_serializer.rb', line 20 def serializable_hash(*args) self.serialize(*args) end |
#serialize(*args) ⇒ Object
The primary interface for extracting a native Ruby types. This works both for records and collections. We accept and ignore ‘*args` for compatibility with active_model_serializers.
14 15 16 |
# File 'lib/rest_framework/serializers/base_serializer.rb', line 14 def serialize(*args) raise NotImplementedError end |