Module: Yogo::DataMapper::RepositoryManager::Model

Defined in:
lib/yogo/datamapper/repository_manager/model.rb

Instance Method Summary collapse

Instance Method Details

#finalize_managed_models!Object

Ensure that Relation models are also managed



27
28
29
30
31
32
33
34
35
36
# File 'lib/yogo/datamapper/repository_manager/model.rb', line 27

def finalize_managed_models!
  models = []
  @managed_models.each do |m|
    models += m.relationships.values.map{|r| r.child_model }
    models += m.relationships.values.map{|r| r.parent_model }
  end
  @managed_models += models
  @managed_models.uniq!
  @managed_models
end

#manage(*args) ⇒ Array<DataMapper::Model>

Class method for informing Project instances about what kinds of models might be stored inside thier Project#managed_repository.

Parameters:

  • model (DataMapper::Model)

    class that might be stored in Project managed_repositories

Returns:



10
11
12
13
14
15
16
17
18
# File 'lib/yogo/datamapper/repository_manager/model.rb', line 10

def manage(*args)
  @managed_models ||= []
  models = args

  @managed_models += models
  @managed_models.uniq!

  @managed_models
end

#managed_modelsArray<DataMapper::Model>

Models that are currently managed by Project instances.

Returns:



22
23
24
# File 'lib/yogo/datamapper/repository_manager/model.rb', line 22

def managed_models
  @managed_models
end