Module: ActiveFedora::Validations::ClassMethods

Defined in:
lib/active_fedora/validations.rb

Instance Method Summary collapse

Instance Method Details

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

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



35
36
37
38
39
40
41
42
43
44
# File 'lib/active_fedora/validations.rb', line 35

def create!(attributes = nil, &block)
  if attributes.is_a?(Array)
    attributes.collect { |attr| create!(attr, &block) }
  else
    object = new(attributes)
    yield(object) if block_given?
    object.save!
    object
  end
end