Module: DataMapper::Associations::ManyToMany

Public Visibility

Public Instance Method Summary

#save
#setup(name, model, options = {})

Setup many to many relationship between two models.

Public Instance Method Details

save

public save
[View source]


33
34
35
36
37
38
# File 'dm-core/lib/dm-core/associations/many_to_many.rb', line 33

def save



  raise NotImplementedError
end

setup

public setup(name, model, options = {})

Setup many to many relationship between two models

[View source]


8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'dm-core/lib/dm-core/associations/many_to_many.rb', line 8

def setup(name, model, options = {})
  raise NotImplementedError
  raise ArgumentError, "+name+ should be a Symbol, but was #{name.class}", caller     unless Symbol === name
  raise ArgumentError, "+options+ should be a Hash, but was #{options.class}", caller unless Hash   === options

  repository_name = model.repository.name

  # TODO: add accessor/mutator to model with class_eval

  model.relationships(repository_name)[name] = Relationship.new(
    name,
    repository_name,
    model.name,
    options.fetch(:class_name, Extlib::Inflection.classify(name)),
    options
  )
end