paul / dm-echo-adapter

A DataMapper Adapter that wraps another adapter, and prints the args and return values to STDOUT

dm-echo-adapter / example.rb
100644 29 lines (15 sloc) 0.401 kb
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
require 'rubygems'
require 'dm-core'
 
require 'lib/dm-echo-adapter'
 
DataMapper.setup(:default, :adapter => :echo, :echo => {:adapter => :in_memory})
 
class Article
  include DataMapper::Resource
 
  property :id, Serial
  property :title, String
  property :text, Text
 
end
 
a = Article.create(:title => "Test", :text => "Lorem Ipsum")
 
Article.all.to_a
 
a.title = "Test Update"
a.save
 
a.destroy