Module: Kalimba::Validations::ClassMethods

Defined in:
lib/kalimba/validations.rb

Instance Method Summary collapse

Instance Method Details

#create!(attributes = {}, &block) ⇒ Object

Creates an object just like Persistence.create but calls save! instead of save so an exception is raised if the record is invalid.



31
32
33
34
35
36
37
# File 'lib/kalimba/validations.rb', line 31

def create!(attributes = {}, &block)
  if attributes.is_a?(Array)
    attributes.each { |attr| create!(attr, &block) }
  else
    create(attributes, &block) || (raise RecordInvalid, self)
  end
end