Sha256: 3c1e5110fd53b15f612f75ebe594d21947ca24c395ab0946125504af5da3b2e2

Contents?: true

Size: 950 Bytes

Versions: 2

Compression:

Stored size: 950 Bytes

Contents

# frozen_string_literal: true

require "rom/schema"
require "rom/http/types"

module ROM
  module HTTP
    class Schema < ROM::Schema
      # Customized output hash constructor which symbolizes keys
      # and optionally applies custom read-type coercions
      #
      # @api private
      def to_output_hash
        Types::Hash
          .schema(map { |attr| [attr.key, attr.to_read_type] }.to_h)
          .with_key_transform(&:to_sym)
      end

      # To maintain compatibility with other adapters
      #
      # @api private
      def qualified
        self
      end

      # Internal hook used during setup process
      #
      # @see Schema#finalize_associations!
      #
      # @api private
      def finalize_associations!(relations:)
        super do
          associations.map do |definition|
            HTTP::Associations.const_get(definition.type).new(definition, relations)
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rom-http-0.10.0 lib/rom/http/schema.rb
rom-http-0.9.0 lib/rom/http/schema.rb