public
Rubygem
Description: DataMapper - Core
Homepage: http://datamapper.org
Clone URL: git://github.com/sam/dm-core.git
Search Repo:
merge with latest origin
Pascal (author)
Sat May 17 00:52:12 -0700 2008
commit  adef05b2502be68be9652797a552dc8b171d7b2b
tree    1b1a4dcc81cb58e771326a7bb126cced62d58e3e
parent  aec2bdbcd1bf40aaac6d8ad41167f848463386e7 parent  3c64ffb88f5b1226d9754244dcbe207015c90440
...
9
10
11
12
 
13
14
15
...
9
10
11
 
12
13
14
15
0
@@ -9,7 +9,7 @@
0
         raise ArgumentError, "+name+ should be a Symbol, but was #{name.class}", caller unless Symbol === name
0
         raise ArgumentError, "+options+ should be a Hash, but was #{options.class}", caller unless Hash === options
0
 
0
- child_model_name = DataMapper::Inflection.demodulize(self.name)
0
+ child_model_name = self.name
0
         parent_model_name = options[:class_name] || DataMapper::Inflection.classify(name)
0
 
0
         relationship = relationships(repository.name)[name] = Relationship.new(
...
84
85
86
 
 
 
 
 
87
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
88
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
90
91
...
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
0
@@ -84,8 +84,69 @@
0
       many_to_one :parent, :class_name => "Node", :child_key => [ :parent_id ]
0
     end
0
   end
0
+
0
+ module Models
0
+
0
+ class Project
0
+ include DataMapper::Resource
0
 
0
+ property :title, String, :length => 255, :key => true
0
+ property :summary, DataMapper::Types::Text
0
+
0
+ repository(:sqlite3) do
0
+ one_to_many :tasks, :class_name => "Models::Task"
0
+ end
0
+ end
0
+
0
+ class Task
0
+ include DataMapper::Resource
0
+
0
+ property :title, String, :length => 255, :key => true
0
+ property :description, DataMapper::Types::Text
0
+ property :project_title, String, :length => 255
0
+
0
+ repository(:sqlite3) do
0
+ many_to_one :project, :class_name => "Models::Project"
0
+ end
0
+ end
0
+
0
+ end
0
+
0
   describe DataMapper::Associations do
0
+
0
+ describe "namespaced associations" do
0
+ before do
0
+ @adapter = repository(:sqlite3).adapter
0
+ Models::Project.auto_migrate!(:sqlite3)
0
+ Models::Task.auto_migrate!(:sqlite3)
0
+ end
0
+
0
+ it 'should allow namespaced classes in parent and child' do
0
+ repository(:sqlite3) do
0
+ m = Models::Project.new(:title => "p1", :summary => "sum1")
0
+ m.tasks << Models::Task.new(:title => "t1", :description => "desc 1")
0
+ m.save
0
+ end
0
+
0
+ t = repository(:sqlite3) do
0
+ Models::Task.first(:title => "t1")
0
+ end
0
+
0
+ t.project.should_not be_nil
0
+ t.project.title.should == 'p1'
0
+ t.project.tasks.size.should == 1
0
+
0
+ p = repository(:sqlite3) do
0
+ Models::Project.first(:title => 'p1')
0
+ end
0
+
0
+ p.tasks.size.should == 1
0
+ p.tasks[0].title.should == "t1"
0
+ end
0
+
0
+
0
+ end
0
+
0
     describe "many to one associations" do
0
       before do
0
         @adapter = repository(:sqlite3).adapter

Comments

    No one has commented yet.