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)

Methods

Public Instance methods

Default fauxture name. Usually :default.

@returns [Symbol] default fauxture name @api public

fix(name = default_fauxture_name, &blk)

Alias for fixture

Adds a fixture to record map. Block is supposed to return a hash of attributes.

@param name [Symbol, String] Name of the fixture @param blk [Proc] A proc that returns fixture attributes

@returns nil

@api public

gen(name = default_fauxture_name, attributes = {})

Alias for generate

gen!(name = default_fauxture_name, attributes = {})

Alias for generate!

gen_attrs(name = default_fauxture_name)

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

[Validate]