Class: AsyncTransaction::BaseSerializer
- Inherits:
-
Object
- Object
- AsyncTransaction::BaseSerializer
- Includes:
- JSONAPI::Serializer
- Defined in:
- app/serializers/async_transaction/base_serializer.rb
Instance Method Summary collapse
-
#serializable_hash ⇒ Object
This is needed to set the correct type based on the object(s) being serialized.
Instance Method Details
#serializable_hash ⇒ Object
This is needed to set the correct type based on the object(s) being serialized
15 16 17 18 19 20 21 22 23 |
# File 'app/serializers/async_transaction/base_serializer.rb', line 15 def serializable_hash hash = super if hash[:data].is_a?(Array) hash[:data].each_with_index { |h, i| h[:type] = @resource[i].class.name.underscore.gsub('/', '_').pluralize } else hash[:data][:type] = @resource.class.name.underscore.gsub('/', '_').pluralize end hash end |