Sha256: 0b7f94a141a0230e5b8fe29a5c980ea37955e3466d7b833887263154693e8250

Contents?: true

Size: 643 Bytes

Versions: 5

Compression:

Stored size: 643 Bytes

Contents

require 'rom/types'
require 'rom/schema'

module ROM
  module Elasticsearch
    # Elasticsearch relation schema
    #
    # @api public
    class Schema < ROM::Schema
      # Return a hash with mapping properties
      #
      # @api private
      def to_properties
        select(&:properties?).map { |attr| [attr.name, attr.properties] }.to_h
      end

      # Customized output hash constructor which symbolizes keys
      # and optionally applies custom read-type coercions
      #
      # @api private
      def to_output_hash
        Types::Hash.symbolized(map { |attr| [attr.key, attr.to_read_type] }.to_h)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rom-elasticsearch-0.3.0 lib/rom/elasticsearch/schema.rb
rom-elasticsearch-0.2.1 lib/rom/elasticsearch/schema.rb
rom-elasticsearch-0.2.0 lib/rom/elasticsearch/schema.rb
rom-elasticsearch-0.1.1 lib/rom/elasticsearch/schema.rb
rom-elasticsearch-0.1.0 lib/rom/elasticsearch/schema.rb