Sha256: 552401e132038337f4fe014af26c5eaf91f4f236ea4914e7578011cbe1265eb1

Contents?: true

Size: 791 Bytes

Versions: 26

Compression:

Stored size: 791 Bytes

Contents

require_relative "success_serializer"

module Foobara
  module CommandConnectors
    module Serializers
      class EntitiesToPrimaryKeysSerializer < SuccessSerializer
        def serialize(object)
          case object
          when Entity
            # TODO: handle polymorphism? Would require iterating over the result type not the object!
            # Is there maybe prior art for this in the associations stuff?
            object.primary_key
          when Model
            object.attributes
          when Array
            object.map { |element| serialize(element) }
          when Hash
            object.to_h do |key, value|
              [serialize(key), serialize(value)]
            end
          else
            object
          end
        end
      end
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
foobara-0.0.26 projects/command_connectors/src/serializers/entities_to_primary_keys_serializer.rb
foobara-0.0.25 projects/command_connectors/src/serializers/entities_to_primary_keys_serializer.rb
foobara-0.0.24 projects/command_connectors/src/serializers/entities_to_primary_keys_serializer.rb
foobara-0.0.23 projects/command_connectors/src/serializers/entities_to_primary_keys_serializer.rb
foobara-0.0.22 projects/command_connectors/src/serializers/entities_to_primary_keys_serializer.rb
foobara-0.0.21 projects/command_connectors/src/serializers/entities_to_primary_keys_serializer.rb
foobara-0.0.20 projects/command_connectors/src/serializers/entities_to_primary_keys_serializer.rb
foobara-0.0.19 projects/command_connectors/src/serializers/entities_to_primary_keys_serializer.rb
foobara-0.0.18 projects/command_connectors/src/serializers/entities_to_primary_keys_serializer.rb
foobara-0.0.17 projects/command_connectors/src/serializers/entities_to_primary_keys_serializer.rb
foobara-0.0.16 projects/command_connectors/src/serializers/entities_to_primary_keys_serializer.rb
foobara-0.0.15 projects/command_connectors/src/serializers/entities_to_primary_keys_serializer.rb
foobara-0.0.14 projects/command_connectors/src/serializers/entities_to_primary_keys_serializer.rb
foobara-0.0.13 projects/command_connectors/src/serializers/entities_to_primary_keys_serializer.rb
foobara-0.0.12 projects/command_connectors/src/serializers/entities_to_primary_keys_serializer.rb
foobara-0.0.11 projects/command_connectors/src/serializers/entities_to_primary_keys_serializer.rb
foobara-0.0.10 projects/command_connectors/src/serializers/entities_to_primary_keys_serializer.rb
foobara-0.0.9 projects/command_connectors/src/serializers/entities_to_primary_keys_serializer.rb
foobara-0.0.8 projects/command_connectors/src/serializers/entities_to_primary_keys_serializer.rb
foobara-0.0.7 projects/command_connectors/src/serializers/entities_to_primary_keys_serializer.rb