Module: Elasticsearch::Persistence::Model::Store::ClassMethods

Defined in:
lib/elasticsearch/persistence/model/store.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#create(attributes, options = {}) ⇒ Object

Creates a class instance, saves it, if validations pass, and returns it

Examples:

Create a new person


Person.create name: 'John Smith'
# => #<Person:0x007f889e302b30 ... @id="bG7yQDAXRhCi3ZfVcx6oAA", @name="John Smith" ...>

Returns:

  • (Object)

    The model instance



19
20
21
22
23
# File 'lib/elasticsearch/persistence/model/store.rb', line 19

def create(attributes, options = {})
  object = self.new(attributes)
  object.save(options)
  object
end