Module: Machinist::ActiveRecordExtensions::ClassMethods

Defined in:
lib/machinist/active_record.rb

Instance Method Summary collapse

Instance Method Details

#make(*args, &block) ⇒ Object



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

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| ... } ⇒ Object

Yields:

  • (object)


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

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

#plan(*args) ⇒ Object



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

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