Method: Algolia::Search::Hit#initialize

Defined in:
lib/algolia/models/search/hit.rb

#initialize(attributes = {}) ⇒ Hit

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/algolia/models/search/hit.rb', line 61

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    raise ArgumentError, "The input argument (attributes) must be a hash in `Algolia::Hit` initialize method"
  end

  if attributes.key?(:object_id)
    self.object_id = attributes[:object_id]
  else
    self.object_id = nil
  end

  if attributes.key?(:_highlight_result)
    if (value = attributes[:_highlight_result]).is_a?(Hash)
      self._highlight_result = value
    end
  end

  if attributes.key?(:_snippet_result)
    if (value = attributes[:_snippet_result]).is_a?(Hash)
      self._snippet_result = value
    end
  end

  if attributes.key?(:_ranking_info)
    self._ranking_info = attributes[:_ranking_info]
  end

  if attributes.key?(:_distinct_seq_id)
    self._distinct_seq_id = attributes[:_distinct_seq_id]
  end

  # add extra attribute to additional_properties
  self.additional_properties ||= {}
  self.additional_properties.merge!(attributes.reject { |k, _| self.class.attribute_map.key?(k.to_sym) })
end