module ActiveRepository::Writers
Public Instance Methods
create(attributes={})
click to toggle source
Creates an object and persists it.
# File lib/active_repository/writers.rb, line 5 def create(attributes={}) attributes = attributes.symbolize_keys if attributes.respond_to?(:symbolize_keys) object = self.new(attributes) if object.present? && object.valid? if persistence_class == self object.id = nil unless exists?(object.id) object.save else object = PersistenceAdapter.create(self, object.attributes) end end new_object = serialize!(object.reload.attributes) new_object.valid? new_object end