Module: Waves::Layers::ORM::DataMapper

Defined in:
lib/waves/layers/orm/providers/data_mapper.rb

Overview

Work in Progress

Class Method Summary collapse

Class Method Details

.included(app) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/waves/layers/orm/providers/data_mapper.rb', line 8

def self.included(app)
  gem 'dm-core', '=0.9.0'

  require 'data_mapper'
  
  def app.database
    @adapter ||= ::DataMapper.setup(:main_repository, config.database[:database])
  end
  
  app.auto_eval :Models do
    auto_load true, :directories => [:models]
  end

  app.auto_eval :Configurations do
    auto_eval :Mapping do
      before true do
        app.database #force adapter init if not already done
        ::DataMapper::Repository.context.push(::DataMapper::Repository.new(:main_repository))
      end
      always true do
        ::DataMapper::Repository.context.pop
      end
    end
  end
    
end