Class: Elastic::Types::BaseType

Inherits:
Core::Serializer show all
Defined in:
lib/elastic/types/base_type.rb

Direct Known Subclasses

NestedType, Elastic::Type

Instance Attribute Summary

Attributes inherited from Core::Serializer

#object

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Core::Serializer

#as_elastic_document, #as_elastic_source, #fields, original_value_occluded?

Constructor Details

#initialize(_object) ⇒ BaseType

Returns a new instance of BaseType.



28
29
30
# File 'lib/elastic/types/base_type.rb', line 28

def initialize(_object)
  super(self.class.definition, _object)
end

Class Method Details

.definitionObject



13
14
15
16
17
18
19
20
21
22
# File 'lib/elastic/types/base_type.rb', line 13

def self.definition
  @definition ||= begin
    pre_definition.fields.each do |field|
      field.disable_mapping_inference if original_value_occluded? field.name
    end

    pre_definition.freeze
    pre_definition
  end
end

.freeze_definitionObject



24
25
26
# File 'lib/elastic/types/base_type.rb', line 24

def self.freeze_definition
  definition # calling definition freezes it
end

.pre_definitionObject



7
8
9
10
11
# File 'lib/elastic/types/base_type.rb', line 7

def self.pre_definition
  @pre_definition ||= Elastic::Core::Definition.new.tap do |definition|
    definition.target = default_target unless default_target.nil?
  end
end

.target=(_name_or_class) ⇒ Object



3
4
5
# File 'lib/elastic/types/base_type.rb', line 3

def self.target=(_name_or_class)
  pre_definition.target = _name_or_class
end