Class: DataMapper::Associations::ManyToOne::Relationship

Class | DataMapper::Associations::ManyToOne::Relationship
In: | lib/dm-core/associations/many_to_one.rb
Parent: | Associations::Relationship

Relationship class with implementation specific to n side of 1 to n association

### Methods

child_key get new nullable? resource_for set source_key

### Constants

OPTIONS | = | superclass::OPTIONS.dup << :nullable

### External Aliases

child_repository_name | -> | source_repository_name
| TODO: document @api semipublic
child_model | -> | source_model
| TODO: document @api semipublic
parent_repository_name | -> | target_repository_name
| TODO: document @api semipublic
parent_model | -> | target_model
| TODO: document @api semipublic
parent_key | -> | target_key
| TODO: document @api semipublic

### Public Class methods

new(name, source_model, target_model, options = {})

Initializes the relationship, always using max cardinality of 1.

@api semipublic

### Public Instance methods

child_key()

Returns a set of keys that identify child model

@return [DataMapper::PropertySet] a set of properties that identify child model @api private

get(source, other_query = nil)

Loads and returns association target (ex.: author) for given source resource (ex.: article)

@param source [DataMapper::Resource]

      Child object (ex.: instance of article)

@param other_query [DataMapper::Query]

      Query options

@api semipublic

nullable?()

TODO: document @api semipublic

resource_for(source, other_query = nil)

Returns a Resource for this relationship with a given source

@param [Resource] source

      A Resource to scope the collection with

@param [Query] other_query (optional)

      A Query to further scope the collection with

@return [Resource]

      The resource scoped to the relationship, source and query

@api private

set(source, target)

Sets value of association target (ex.: author) for given source resource (ex.: article)

@param source [DataMapper::Resource]

      Child object (ex.: instance of article)

@param source [DataMapper::Resource]

      Parent object (ex.: instance of author)

@api semipublic

source_key()

Alias for child_key

[Validate]