Module: Machinist::DataMapperExtensions

Defined in:
lib/machinist/data_mapper.rb

Instance Method Summary collapse

Instance Method Details

#make(*args, &block) ⇒ Object



59
60
61
62
63
64
65
66
# File 'lib/machinist/data_mapper.rb', line 59

def make(*args, &block)
  lathe = Lathe.run(Machinist::DataMapperAdapter, self.new, *args)
  unless Machinist.nerfed?
    lathe.object.save || raise("Save failed")
    lathe.object.reload
  end
  lathe.object(&block)
end

#make_unsaved(*args) ⇒ Object



68
69
70
71
72
# File 'lib/machinist/data_mapper.rb', line 68

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

#plan(*args) ⇒ Object



74
75
76
77
# File 'lib/machinist/data_mapper.rb', line 74

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