Module: Machinist::ActiveRecordExtensions::ClassMethods

Defined in:
lib/machinist/active_record.rb

Instance Method Summary collapse

Instance Method Details

#make(*args, &block) ⇒ Object



51
52
53
54
55
56
57
58
# File 'lib/machinist/active_record.rb', line 51

def make(*args, &block)
  lathe = Lathe.run(Machinist::ActiveRecordAdapter, self.new, *args)
  unless Machinist.nerfed?
    lathe.object.save!
    lathe.object.reload
  end
  lathe.object(&block)
end

#make_unsaved(*args) ⇒ Object



60
61
62
63
64
# File 'lib/machinist/active_record.rb', line 60

def make_unsaved(*args)
  returning(Machinist.with_save_nerfed { make(*args) }) do |object|
    yield object if block_given?
  end
end

#plan(*args) ⇒ Object



66
67
68
69
# File 'lib/machinist/active_record.rb', line 66

def plan(*args)
  lathe = Lathe.run(Machinist::ActiveRecordAdapter, self.new, *args)
  Machinist::ActiveRecordAdapter.assigned_attributes_without_associations(lathe)
end