Method: Waistband::Index#save

Defined in:
lib/waistband/index.rb

#save(*args) ⇒ Object



90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/waistband/index.rb', line 90

def save(*args)
  body_hash = args.extract_options!
  id = args.first
  _type = body_hash.delete(:_type) || body_hash.delete('_type') || default_type_name

  # map everything to strings if need be
  body_hash = stringify_all(body_hash) if @stringify

  saved = client.index(
    index: config_name,
    type: _type,
    id: id,
    body: body_hash
  )

  saved['_id'].present?
end