module ActiveFedora::Validations::ClassMethods

Public Instance Methods

create!(attributes = nil) { |object| ... } click to toggle source

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

# 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