module Dry::ElasticModel::Schema

Public Instance Methods

mapping() click to toggle source
# File lib/dry/elastic_model/schema.rb, line 8
def mapping
  {
    name.downcase.to_sym => {
      properties: schema.inject({}) do |h, type|
        attr = type.name
        definition = type.lax

        opts = definition.meta.fetch(:opts, {})
        h.merge(
          attr => { type: definition.meta.fetch(:es_name) }.merge(opts)
        )
      end
    }
  }
end
parse_definition(definition) click to toggle source

@param definition [Dry::Types::Definition]

# File lib/dry/elastic_model/schema.rb, line 25
def parse_definition(definition)
  definition.meta[:es_name]
end