Class: ROM::Elasticsearch::Commands::Create

Inherits:
Commands::Create
  • Object
show all
Defined in:
lib/rom/elasticsearch/commands.rb

Overview

Create command

API:

  • public

Instance Method Summary collapse

Instance Method Details

#execute(attributes) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/rom/elasticsearch/commands.rb', line 16

def execute(attributes)
  tuple = input[attributes]

  result =
    if _id
      dataset.params(id: tuple.fetch(_id)).put(tuple)
    else
      dataset.put(tuple)
    end
  [relation.get(result["_id"]).one]
end