Module | DataMapper::Model |
In: |
lib/dm-sweatshop/model.rb
|
Methods added to this module are available on classes that include DataMapper::Resource.
This lets you use Person.pick(:michael) instead of DataMapper::Sweatshop.pick(Person, :michael)
Creates an instance from hash of attributes, saves it and adds it to the record map. Attributes given as the second argument are merged into attributes from fixture.
If record is valid because of duplicated property value, this method does a retry.
@param name [Symbol] @param attributes [Hash]
@api public
@returns [DataMapper::Resource] added instance
Same as generate except that it uses Model#create!. It forces invalid objects to be saved in the repository.
@param name [Symbol] @param attributes [Hash]
@api public
@returns [DataMapper::Resource] added instance
Returns a Hash of attributes from the model map.
@param name [Symbol] name of the fauxture to use
@returns [Hash] existing instance of a model from the model map @raises NoFixtureExist when requested fixture does not exist in the model map
@api public
Creates an instance from given hash of attributes and adds it to records map without saving.
@param name [Symbol] name of the fauxture to use @param attributes [Hash]
@api private
@returns [DataMapper::Resource] added instance
Returns a pre existing instance of a model from the record map
@param name [Symbol] name of the fauxture to pick
@returns [DataMapper::Resource] existing instance of a model from the record map @raises DataMapper::Sweatshop::NoFixtureExist when requested fixture does not exist in the record map
@api public