Method: DataMapper::Associations::Relationship#child_key

Defined in:
lib/dm-core/associations/relationship.rb

#child_keyPropertySet Also known as: relationship_child_key

Returns a set of keys that identify the target model

Returns:

  • (PropertySet)

    a set of properties that identify the target model



195
196
197
198
199
200
201
202
203
204
205
206
207
# File 'lib/dm-core/associations/relationship.rb', line 195

def child_key
  return @child_key if defined?(@child_key)

  repository_name = child_repository_name || parent_repository_name
  properties      = child_model.properties(repository_name)

  @child_key = if @child_properties
    child_key = properties.values_at(*@child_properties)
    properties.class.new(child_key).freeze
  else
    properties.key
  end
end