Class: NaranyaEcm::Search::Hit

Inherits:
Object
  • Object
show all
Defined in:
lib/naranya_ecm/search/hit.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Hit

Returns a new instance of Hit.



4
5
6
7
8
9
10
11
12
# File 'lib/naranya_ecm/search/hit.rb', line 4

def initialize(attributes={})
  @id         = attributes.delete :_id
  @type       = attributes.delete :_type
  @score      = attributes.delete :_score

  source      = attributes.delete :_source
  @updated_at = source.has_key?(:updated_at) ? source.delete(:updated_at).to_datetime : nil
  @order      = attributes.delete :order
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



3
4
5
# File 'lib/naranya_ecm/search/hit.rb', line 3

def id
  @id
end

#orderObject (readonly)

Returns the value of attribute order.



3
4
5
# File 'lib/naranya_ecm/search/hit.rb', line 3

def order
  @order
end

#scoreObject (readonly)

Returns the value of attribute score.



3
4
5
# File 'lib/naranya_ecm/search/hit.rb', line 3

def score
  @score
end

#typeObject (readonly)

Returns the value of attribute type.



3
4
5
# File 'lib/naranya_ecm/search/hit.rb', line 3

def type
  @type
end

#updated_atObject (readonly)

Returns the value of attribute updated_at.



3
4
5
# File 'lib/naranya_ecm/search/hit.rb', line 3

def updated_at
  @updated_at
end

Instance Method Details

#klassObject



14
15
16
# File 'lib/naranya_ecm/search/hit.rb', line 14

def klass
  @klass ||= "NaranyaEcm::#{type.classify}".constantize
end