Method: DataMapper::Collection#new

Defined in:
lib/dm-core/collection.rb

#new(attributes = {}) ⇒ Resource

Initializes a Resource and appends it to the Collection

Parameters:

  • attributes (Hash) (defaults to: {})

    Attributes with which to initialize the new resource

Returns:

  • (Resource)

    a new Resource initialized with attributes



778
779
780
781
782
# File 'lib/dm-core/collection.rb', line 778

def new(attributes = {})
  resource = repository.scope { model.new(attributes) }
  self << resource
  resource
end