Class: Arelastic::Mappings::Type

Inherits:
Nodes::Node show all
Defined in:
lib/arelastic/mappings/type.rb

Direct Known Subclasses

Binary, Boolean, Date, MultiField, Number, Object, String

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Nodes::Node

#==, #convert_to_elastic, #read_option!

Methods included from Arities::Binary

#binary

Methods included from Arities::Polyadic

#polyadic

Methods included from Arities::Unary

#unary

Constructor Details

#initialize(field, options = {}) ⇒ Type

Returns a new instance of Type.



12
13
14
15
# File 'lib/arelastic/mappings/type.rb', line 12

def initialize(field, options = {})
  @field = field
  @options = options
end

Class Attribute Details

.typeObject (readonly)

Returns the value of attribute type.



5
6
7
# File 'lib/arelastic/mappings/type.rb', line 5

def type
  @type
end

Instance Attribute Details

#fieldObject (readonly)

Returns the value of attribute field.



11
12
13
# File 'lib/arelastic/mappings/type.rb', line 11

def field
  @field
end

#optionsObject (readonly)

Returns the value of attribute options.



11
12
13
# File 'lib/arelastic/mappings/type.rb', line 11

def options
  @options
end

Class Method Details

.for_type(type) ⇒ Object



6
7
8
# File 'lib/arelastic/mappings/type.rb', line 6

def for_type(type)
  @type = type
end

Instance Method Details

#as_elasticObject



17
18
19
20
21
# File 'lib/arelastic/mappings/type.rb', line 17

def as_elastic
  params = {'type' => self.class.type}.update(options)

  { field => params }
end