Module: ActiveGroonga::Validations::ClassMethods — activegroonga - ラングバ

Module: ActiveGroonga::Validations::ClassMethods

Defined in:
lib/active_groonga/validations.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) create!(attributes = nil, &block)



38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/active_groonga/validations.rb', line 38

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