File: data_mapper_test_connector.rb

package info (click to toggle)
ruby-will-paginate 3.3.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 444 kB
  • sloc: ruby: 2,940; sh: 50; makefile: 2
file content (34 lines) | stat: -rw-r--r-- 635 bytes parent folder | download
1
2
3
4
5
6
7
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
34
require 'sqlite3'
require 'dm-core'
require 'dm-core/support/logger'
require 'dm-migrations'

class Animal
  include DataMapper::Resource

  property :id, Serial
  property :name, String
  property :notes, Text
end

class Ownership
  include DataMapper::Resource

  belongs_to :animal, :key => true
  belongs_to :human, :key => true
end

class Human
  include DataMapper::Resource

  property :id, Serial
  property :name, String

  has n, :ownerships
  has 1, :pet, :model => 'Animal', :through => :ownerships, :via => :animal
end

if 'irb' == $0
  DataMapper.logger.set_log($stdout, :debug)
  DataMapper.logger.auto_flush = true
end