Skip to content

Commit e44dc3a

Browse files
committed
Updated README
1 parent 4cd2d3f commit e44dc3a

File tree

1 file changed

+43
-3
lines changed

1 file changed

+43
-3
lines changed

README.rdoc

+43-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,46 @@
1-
= dm-schema_reflector
1+
= dm-reflection
22

3-
Description goes here.
3+
For now, this gem only allows you to print the ruby source for any DataMapper::Model, taking all property and relationship definitions into account. However, the plan is to be able to reflect on an existing relational database schema and export the corresponding datamapper model definitions to ruby source files. Think of it as active_record and annotate_models combined to do something useful with legacy databases.
4+
5+
require 'rubygems'
6+
require 'dm-core'
7+
require 'dm-reflection/builders/source_builder'
8+
9+
class Project
10+
11+
include DataMapper::Resource
12+
13+
property :id, Serial
14+
15+
property :name, String, :required => true, :length => 200
16+
property :created_at, DateTime
17+
property :updated_at, DateTime
18+
19+
has 0..n, :project_tasks
20+
has 0..n, :tasks, :through => :project_tasks
21+
has 0..n, :people, :through => Resource
22+
23+
end
24+
25+
Project.to_ruby # produces this nicely formatted ruby code
26+
27+
<<-RUBY
28+
class Project
29+
30+
include DataMapper::Resource
31+
32+
property :id, Serial
33+
34+
property :name, String, :required => true, :length => 200
35+
property :created_at, DateTime
36+
property :updated_at, DateTime
37+
38+
has 0..n, :project_tasks
39+
has 0..n, :tasks, :through => :project_tasks
40+
has 0..n, :people, :through => Resource
41+
42+
end
43+
RUBY
444

545
== Note on Patches/Pull Requests
646

@@ -14,4 +54,4 @@ Description goes here.
1454

1555
== Copyright
1656

17-
Copyright (c) 2009 snusnu. See LICENSE for details.
57+
Copyright (c) 2009 Martin Gamsjaeger (snusnu). See LICENSE for details.

0 commit comments

Comments
 (0)