class ROM::Elasticsearch::Commands::Create

Create command

@api public

Public Instance Methods

execute(attributes) click to toggle source

@api private

# 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

Private Instance Methods

_id() click to toggle source
# File lib/rom/elasticsearch/commands.rb, line 35
def _id
  relation.schema.primary_key_name
end
dataset() click to toggle source

@api private

# File lib/rom/elasticsearch/commands.rb, line 31
def dataset
  relation.dataset
end