Method: Epiphy::Repository::ClassMethods#create
- Defined in:
- lib/epiphy/repository.rb
#create(entity) ⇒ Object
Creates a record in the database for the given entity. It assigns the ‘id` attribute, in case of success.
If already persisted (‘id` present), it will try to insert use that id and will raise an error if the `id` is already exist
336 337 338 339 340 341 342 343 344 345 346 347 |
# File 'lib/epiphy/repository.rb', line 336 def create(entity) #unless entity.id begin result = @adapter.create(collection, to_document(entity)) entity.id = result rescue Epiphy::Model::EntityExisted => e raise e rescue RethinkDB::RqlRuntimeError => e raise Epiphy::Model::RuntimeError, e. end #end end |