dm-core 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/Gemfile +19 -20
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/dm-core.gemspec +15 -12
- data/lib/dm-core.rb +23 -14
- data/lib/dm-core/adapters.rb +7 -3
- data/lib/dm-core/adapters/abstract_adapter.rb +3 -9
- data/lib/dm-core/associations/many_to_many.rb +1 -1
- data/lib/dm-core/associations/many_to_one.rb +3 -4
- data/lib/dm-core/associations/one_to_many.rb +2 -2
- data/lib/dm-core/associations/one_to_one.rb +1 -1
- data/lib/dm-core/collection.rb +4 -6
- data/lib/dm-core/model.rb +22 -32
- data/lib/dm-core/model/property.rb +15 -39
- data/lib/dm-core/property.rb +75 -87
- data/lib/dm-core/property/discriminator.rb +3 -3
- data/lib/dm-core/property/lookup.rb +42 -0
- data/lib/dm-core/property/object.rb +5 -0
- data/lib/dm-core/property/serial.rb +6 -1
- data/lib/dm-core/query/conditions/comparison.rb +3 -3
- data/lib/dm-core/query/conditions/operation.rb +3 -3
- data/lib/dm-core/resource.rb +2 -2
- data/lib/dm-core/resource/state/dirty.rb +2 -2
- data/lib/dm-core/spec/lib/spec_helper.rb +11 -3
- data/lib/dm-core/spec/setup.rb +2 -2
- data/{spec/public/shared/property_shared_spec.rb → lib/dm-core/spec/shared/public/property_spec.rb} +51 -20
- data/{spec/semipublic/shared/property_shared_spec.rb → lib/dm-core/spec/shared/semipublic/property_spec.rb} +22 -26
- data/lib/dm-core/support/descendant_set.rb +84 -0
- data/lib/dm-core/support/naming_conventions.rb +8 -8
- data/lib/dm-core/types/discriminator.rb +2 -2
- data/spec/public/associations/many_to_one_with_custom_fk_spec.rb +49 -0
- data/spec/public/finalize_spec.rb +42 -11
- data/spec/public/property/discriminator_spec.rb +6 -6
- data/spec/semipublic/adapters/abstract_adapter_spec.rb +1 -1
- data/spec/semipublic/property/lookup_spec.rb +26 -0
- data/spec/semipublic/property_spec.rb +43 -0
- data/spec/semipublic/resource/state/dirty_spec.rb +4 -2
- data/spec/support/{types → properties}/huge_integer.rb +5 -5
- data/tasks/local_gemfile.rake +5 -7
- metadata +15 -19
- data/lib/dm-core/model/descendant_set.rb +0 -81
data/.gitignore
CHANGED
data/Gemfile
CHANGED
@@ -71,24 +71,24 @@
|
|
71
71
|
source 'http://rubygems.org'
|
72
72
|
|
73
73
|
DATAMAPPER = 'git://github.com/datamapper'
|
74
|
-
DM_VERSION = '~> 1.0.
|
74
|
+
DM_VERSION = '~> 1.0.1'
|
75
75
|
|
76
76
|
group :runtime do # Runtime dependencies (as in the gemspec)
|
77
77
|
|
78
78
|
if ENV['EXTLIB']
|
79
|
-
gem 'extlib', '~> 0.9.15',
|
79
|
+
gem 'extlib', '~> 0.9.15', :git => "#{DATAMAPPER}/extlib.git"
|
80
80
|
else
|
81
|
-
gem 'activesupport', '~> 3.0.0
|
81
|
+
gem 'activesupport', '~> 3.0.0', :git => 'git://github.com/rails/rails.git', :branch => '3-0-stable', :require => nil
|
82
82
|
end
|
83
83
|
|
84
|
-
gem 'addressable', '~> 2.
|
84
|
+
gem 'addressable', '~> 2.2'
|
85
85
|
|
86
86
|
end
|
87
87
|
|
88
88
|
group(:development) do # Development dependencies (as in the gemspec)
|
89
89
|
|
90
90
|
gem 'rake', '~> 0.8.7'
|
91
|
-
gem 'rspec', '~> 1.3'
|
91
|
+
gem 'rspec', '~> 1.3', :git => 'git://github.com/snusnu/rspec', :branch => 'heckle_fix_plus_gemfile'
|
92
92
|
gem 'jeweler', '~> 1.4'
|
93
93
|
|
94
94
|
end
|
@@ -109,32 +109,31 @@ group :datamapper do # We need this because we want to pin these dependencies to
|
|
109
109
|
gem 'dm-core', DM_VERSION, :path => File.dirname(__FILE__) # Make ourself available to the adapters
|
110
110
|
|
111
111
|
adapters = ENV['ADAPTER'] || ENV['ADAPTERS']
|
112
|
-
adapters = adapters.to_s.
|
112
|
+
adapters = adapters.to_s.tr(',', ' ').split.uniq - %w[ in_memory ]
|
113
113
|
|
114
|
-
|
114
|
+
DO_VERSION = '~> 0.10.2'
|
115
|
+
DM_DO_ADAPTERS = %w[ sqlite postgres mysql oracle sqlserver ]
|
115
116
|
|
116
|
-
|
117
|
-
|
117
|
+
if (do_adapters = DM_DO_ADAPTERS & adapters).any?
|
118
|
+
options = {}
|
119
|
+
options[:git] = "#{DATAMAPPER}/do.git" if ENV['DO_GIT'] == 'true'
|
118
120
|
|
119
|
-
gem 'data_objects', DO_VERSION,
|
121
|
+
gem 'data_objects', DO_VERSION, options.dup
|
120
122
|
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
gem "do_#{adapter}", DO_VERSION, :git => "#{DATAMAPPER}/do.git"
|
125
|
-
end
|
123
|
+
do_adapters.each do |adapter|
|
124
|
+
adapter = 'sqlite3' if adapter == 'sqlite'
|
125
|
+
gem "do_#{adapter}", DO_VERSION, options.dup
|
126
126
|
end
|
127
127
|
|
128
128
|
gem 'dm-do-adapter', DM_VERSION, :git => "#{DATAMAPPER}/dm-do-adapter.git"
|
129
|
+
end
|
129
130
|
|
130
|
-
|
131
|
-
|
132
|
-
end
|
133
|
-
|
131
|
+
adapters.each do |adapter|
|
132
|
+
gem "dm-#{adapter}-adapter", DM_VERSION, :git => "#{DATAMAPPER}/dm-#{adapter}-adapter.git"
|
134
133
|
end
|
135
134
|
|
136
135
|
plugins = ENV['PLUGINS'] || ENV['PLUGIN']
|
137
|
-
plugins =
|
136
|
+
plugins = plugins.to_s.tr(',', ' ').split.push('dm-migrations').uniq
|
138
137
|
|
139
138
|
plugins.each do |plugin|
|
140
139
|
gem plugin, DM_VERSION, :git => "#{DATAMAPPER}/#{plugin}.git"
|
data/Rakefile
CHANGED
@@ -16,7 +16,7 @@ begin
|
|
16
16
|
gem.rubyforge_project = 'datamapper'
|
17
17
|
|
18
18
|
gem.add_dependency 'extlib', '~> 0.9.15'
|
19
|
-
gem.add_dependency 'addressable', '~> 2.
|
19
|
+
gem.add_dependency 'addressable', '~> 2.2'
|
20
20
|
|
21
21
|
gem.add_development_dependency 'rspec', '~> 1.3'
|
22
22
|
gem.add_development_dependency 'jeweler', '~> 1.4'
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.1
|
data/dm-core.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{dm-core}
|
8
|
-
s.version = "1.0.
|
8
|
+
s.version = "1.0.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Dan Kubb"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-09-07}
|
13
13
|
s.description = %q{Faster, Better, Simpler.}
|
14
14
|
s.email = %q{dan.kubb@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -47,7 +47,6 @@ Gem::Specification.new do |s|
|
|
47
47
|
"lib/dm-core/core_ext/try_dup.rb",
|
48
48
|
"lib/dm-core/identity_map.rb",
|
49
49
|
"lib/dm-core/model.rb",
|
50
|
-
"lib/dm-core/model/descendant_set.rb",
|
51
50
|
"lib/dm-core/model/hook.rb",
|
52
51
|
"lib/dm-core/model/is.rb",
|
53
52
|
"lib/dm-core/model/property.rb",
|
@@ -63,6 +62,7 @@ Gem::Specification.new do |s|
|
|
63
62
|
"lib/dm-core/property/discriminator.rb",
|
64
63
|
"lib/dm-core/property/float.rb",
|
65
64
|
"lib/dm-core/property/integer.rb",
|
65
|
+
"lib/dm-core/property/lookup.rb",
|
66
66
|
"lib/dm-core/property/numeric.rb",
|
67
67
|
"lib/dm-core/property/object.rb",
|
68
68
|
"lib/dm-core/property/serial.rb",
|
@@ -95,11 +95,14 @@ Gem::Specification.new do |s|
|
|
95
95
|
"lib/dm-core/spec/lib/spec_helper.rb",
|
96
96
|
"lib/dm-core/spec/setup.rb",
|
97
97
|
"lib/dm-core/spec/shared/adapter_spec.rb",
|
98
|
+
"lib/dm-core/spec/shared/public/property_spec.rb",
|
98
99
|
"lib/dm-core/spec/shared/resource_spec.rb",
|
99
100
|
"lib/dm-core/spec/shared/sel_spec.rb",
|
101
|
+
"lib/dm-core/spec/shared/semipublic/property_spec.rb",
|
100
102
|
"lib/dm-core/support/assertions.rb",
|
101
103
|
"lib/dm-core/support/chainable.rb",
|
102
104
|
"lib/dm-core/support/deprecate.rb",
|
105
|
+
"lib/dm-core/support/descendant_set.rb",
|
103
106
|
"lib/dm-core/support/equalizer.rb",
|
104
107
|
"lib/dm-core/support/hook.rb",
|
105
108
|
"lib/dm-core/support/lazy_array.rb",
|
@@ -122,6 +125,7 @@ Gem::Specification.new do |s|
|
|
122
125
|
"spec/public/associations/many_to_many_spec.rb",
|
123
126
|
"spec/public/associations/many_to_one_spec.rb",
|
124
127
|
"spec/public/associations/many_to_one_with_boolean_cpk_spec.rb",
|
128
|
+
"spec/public/associations/many_to_one_with_custom_fk_spec.rb",
|
125
129
|
"spec/public/associations/one_to_many_spec.rb",
|
126
130
|
"spec/public/associations/one_to_one_spec.rb",
|
127
131
|
"spec/public/associations/one_to_one_with_boolean_cpk_spec.rb",
|
@@ -153,7 +157,6 @@ Gem::Specification.new do |s|
|
|
153
157
|
"spec/public/shared/collection_finder_shared_spec.rb",
|
154
158
|
"spec/public/shared/collection_shared_spec.rb",
|
155
159
|
"spec/public/shared/finder_shared_spec.rb",
|
156
|
-
"spec/public/shared/property_shared_spec.rb",
|
157
160
|
"spec/rcov.opts",
|
158
161
|
"spec/semipublic/adapters/abstract_adapter_spec.rb",
|
159
162
|
"spec/semipublic/adapters/in_memory_adapter_spec.rb",
|
@@ -174,6 +177,7 @@ Gem::Specification.new do |s|
|
|
174
177
|
"spec/semipublic/property/discriminator_spec.rb",
|
175
178
|
"spec/semipublic/property/float_spec.rb",
|
176
179
|
"spec/semipublic/property/integer_spec.rb",
|
180
|
+
"spec/semipublic/property/lookup_spec.rb",
|
177
181
|
"spec/semipublic/property/serial_spec.rb",
|
178
182
|
"spec/semipublic/property/string_spec.rb",
|
179
183
|
"spec/semipublic/property/text_spec.rb",
|
@@ -191,13 +195,12 @@ Gem::Specification.new do |s|
|
|
191
195
|
"spec/semipublic/resource/state_spec.rb",
|
192
196
|
"spec/semipublic/resource_spec.rb",
|
193
197
|
"spec/semipublic/shared/condition_shared_spec.rb",
|
194
|
-
"spec/semipublic/shared/property_shared_spec.rb",
|
195
198
|
"spec/semipublic/shared/resource_shared_spec.rb",
|
196
199
|
"spec/semipublic/shared/resource_state_shared_spec.rb",
|
197
200
|
"spec/semipublic/shared/subject_shared_spec.rb",
|
198
201
|
"spec/spec.opts",
|
199
202
|
"spec/spec_helper.rb",
|
200
|
-
"spec/support/
|
203
|
+
"spec/support/properties/huge_integer.rb",
|
201
204
|
"spec/unit/array_spec.rb",
|
202
205
|
"spec/unit/hash_spec.rb",
|
203
206
|
"spec/unit/hook_spec.rb",
|
@@ -224,6 +227,7 @@ Gem::Specification.new do |s|
|
|
224
227
|
"spec/public/associations/many_to_many_spec.rb",
|
225
228
|
"spec/public/associations/many_to_one_spec.rb",
|
226
229
|
"spec/public/associations/many_to_one_with_boolean_cpk_spec.rb",
|
230
|
+
"spec/public/associations/many_to_one_with_custom_fk_spec.rb",
|
227
231
|
"spec/public/associations/one_to_many_spec.rb",
|
228
232
|
"spec/public/associations/one_to_one_spec.rb",
|
229
233
|
"spec/public/associations/one_to_one_with_boolean_cpk_spec.rb",
|
@@ -255,7 +259,6 @@ Gem::Specification.new do |s|
|
|
255
259
|
"spec/public/shared/collection_finder_shared_spec.rb",
|
256
260
|
"spec/public/shared/collection_shared_spec.rb",
|
257
261
|
"spec/public/shared/finder_shared_spec.rb",
|
258
|
-
"spec/public/shared/property_shared_spec.rb",
|
259
262
|
"spec/semipublic/adapters/abstract_adapter_spec.rb",
|
260
263
|
"spec/semipublic/adapters/in_memory_adapter_spec.rb",
|
261
264
|
"spec/semipublic/associations/many_to_many_spec.rb",
|
@@ -275,6 +278,7 @@ Gem::Specification.new do |s|
|
|
275
278
|
"spec/semipublic/property/discriminator_spec.rb",
|
276
279
|
"spec/semipublic/property/float_spec.rb",
|
277
280
|
"spec/semipublic/property/integer_spec.rb",
|
281
|
+
"spec/semipublic/property/lookup_spec.rb",
|
278
282
|
"spec/semipublic/property/serial_spec.rb",
|
279
283
|
"spec/semipublic/property/string_spec.rb",
|
280
284
|
"spec/semipublic/property/text_spec.rb",
|
@@ -292,12 +296,11 @@ Gem::Specification.new do |s|
|
|
292
296
|
"spec/semipublic/resource/state_spec.rb",
|
293
297
|
"spec/semipublic/resource_spec.rb",
|
294
298
|
"spec/semipublic/shared/condition_shared_spec.rb",
|
295
|
-
"spec/semipublic/shared/property_shared_spec.rb",
|
296
299
|
"spec/semipublic/shared/resource_shared_spec.rb",
|
297
300
|
"spec/semipublic/shared/resource_state_shared_spec.rb",
|
298
301
|
"spec/semipublic/shared/subject_shared_spec.rb",
|
299
302
|
"spec/spec_helper.rb",
|
300
|
-
"spec/support/
|
303
|
+
"spec/support/properties/huge_integer.rb",
|
301
304
|
"spec/unit/array_spec.rb",
|
302
305
|
"spec/unit/hash_spec.rb",
|
303
306
|
"spec/unit/hook_spec.rb",
|
@@ -313,18 +316,18 @@ Gem::Specification.new do |s|
|
|
313
316
|
|
314
317
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
315
318
|
s.add_runtime_dependency(%q<extlib>, ["~> 0.9.15"])
|
316
|
-
s.add_runtime_dependency(%q<addressable>, ["~> 2.
|
319
|
+
s.add_runtime_dependency(%q<addressable>, ["~> 2.2"])
|
317
320
|
s.add_development_dependency(%q<rspec>, ["~> 1.3"])
|
318
321
|
s.add_development_dependency(%q<jeweler>, ["~> 1.4"])
|
319
322
|
else
|
320
323
|
s.add_dependency(%q<extlib>, ["~> 0.9.15"])
|
321
|
-
s.add_dependency(%q<addressable>, ["~> 2.
|
324
|
+
s.add_dependency(%q<addressable>, ["~> 2.2"])
|
322
325
|
s.add_dependency(%q<rspec>, ["~> 1.3"])
|
323
326
|
s.add_dependency(%q<jeweler>, ["~> 1.4"])
|
324
327
|
end
|
325
328
|
else
|
326
329
|
s.add_dependency(%q<extlib>, ["~> 0.9.15"])
|
327
|
-
s.add_dependency(%q<addressable>, ["~> 2.
|
330
|
+
s.add_dependency(%q<addressable>, ["~> 2.2"])
|
328
331
|
s.add_dependency(%q<rspec>, ["~> 1.3"])
|
329
332
|
s.add_dependency(%q<jeweler>, ["~> 1.4"])
|
330
333
|
end
|
data/lib/dm-core.rb
CHANGED
@@ -7,6 +7,10 @@ require 'set'
|
|
7
7
|
require 'time'
|
8
8
|
require 'yaml'
|
9
9
|
|
10
|
+
module DataMapper
|
11
|
+
module Undefined; end
|
12
|
+
end
|
13
|
+
|
10
14
|
begin
|
11
15
|
|
12
16
|
# Prefer active_support
|
@@ -25,6 +29,10 @@ begin
|
|
25
29
|
require 'dm-core/core_ext/object'
|
26
30
|
require 'dm-core/core_ext/string'
|
27
31
|
|
32
|
+
module DataMapper
|
33
|
+
Inflector = ActiveSupport::Inflector
|
34
|
+
end
|
35
|
+
|
28
36
|
rescue LoadError
|
29
37
|
|
30
38
|
# Default to extlib
|
@@ -45,7 +53,7 @@ rescue LoadError
|
|
45
53
|
end
|
46
54
|
end
|
47
55
|
|
48
|
-
module
|
56
|
+
module DataMapper
|
49
57
|
Inflector = Extlib::Inflection
|
50
58
|
end
|
51
59
|
|
@@ -63,19 +71,13 @@ require 'dm-core/core_ext/array'
|
|
63
71
|
|
64
72
|
require 'dm-core/support/chainable'
|
65
73
|
require 'dm-core/support/deprecate'
|
74
|
+
require 'dm-core/support/descendant_set'
|
66
75
|
require 'dm-core/support/equalizer'
|
67
76
|
require 'dm-core/support/assertions'
|
68
77
|
require 'dm-core/support/lazy_array'
|
69
78
|
require 'dm-core/support/local_object_space'
|
70
79
|
require 'dm-core/support/hook'
|
71
80
|
require 'dm-core/support/subject'
|
72
|
-
require 'dm-core/model'
|
73
|
-
require 'dm-core/model/descendant_set'
|
74
|
-
require 'dm-core/model/hook'
|
75
|
-
require 'dm-core/model/is'
|
76
|
-
require 'dm-core/model/scope'
|
77
|
-
require 'dm-core/model/relationship'
|
78
|
-
require 'dm-core/model/property'
|
79
81
|
|
80
82
|
require 'dm-core/collection'
|
81
83
|
|
@@ -102,8 +104,17 @@ require 'dm-core/property/date_time'
|
|
102
104
|
require 'dm-core/property/time'
|
103
105
|
require 'dm-core/property/class'
|
104
106
|
require 'dm-core/property/discriminator'
|
107
|
+
|
108
|
+
require 'dm-core/property/lookup'
|
105
109
|
require 'dm-core/property_set'
|
106
110
|
|
111
|
+
require 'dm-core/model'
|
112
|
+
require 'dm-core/model/hook'
|
113
|
+
require 'dm-core/model/is'
|
114
|
+
require 'dm-core/model/scope'
|
115
|
+
require 'dm-core/model/relationship'
|
116
|
+
require 'dm-core/model/property'
|
117
|
+
|
107
118
|
require 'dm-core/adapters'
|
108
119
|
require 'dm-core/adapters/abstract_adapter'
|
109
120
|
require 'dm-core/associations/relationship'
|
@@ -112,8 +123,6 @@ require 'dm-core/associations/one_to_one'
|
|
112
123
|
require 'dm-core/associations/many_to_one'
|
113
124
|
require 'dm-core/associations/many_to_many'
|
114
125
|
require 'dm-core/identity_map'
|
115
|
-
require 'dm-core/property'
|
116
|
-
require 'dm-core/property_set'
|
117
126
|
require 'dm-core/query'
|
118
127
|
require 'dm-core/query/conditions/operation'
|
119
128
|
require 'dm-core/query/conditions/comparison'
|
@@ -327,15 +336,15 @@ module DataMapper
|
|
327
336
|
raise IncompleteModelError, "#{name} must have at least one property or many to one relationship to be valid"
|
328
337
|
end
|
329
338
|
|
330
|
-
if model.key(repository_name).empty?
|
331
|
-
raise IncompleteModelError, "#{name} must have a key to be valid"
|
332
|
-
end
|
333
|
-
|
334
339
|
# initialize join models and target keys
|
335
340
|
relationships.each do |relationship|
|
336
341
|
relationship.child_key
|
337
342
|
relationship.through if relationship.respond_to?(:through)
|
338
343
|
relationship.via if relationship.respond_to?(:via)
|
339
344
|
end
|
345
|
+
|
346
|
+
if model.key(repository_name).empty?
|
347
|
+
raise IncompleteModelError, "#{name} must have a key to be valid"
|
348
|
+
end
|
340
349
|
end
|
341
350
|
end
|
data/lib/dm-core/adapters.rb
CHANGED
@@ -129,7 +129,7 @@ module DataMapper
|
|
129
129
|
# @api private
|
130
130
|
def adapter_class(name)
|
131
131
|
adapter_name = normalize_adapter_name(name)
|
132
|
-
class_name = (
|
132
|
+
class_name = (DataMapper::Inflector.camelize(adapter_name) << 'Adapter').to_sym
|
133
133
|
load_adapter(adapter_name) unless const_defined?(class_name)
|
134
134
|
const_get(class_name)
|
135
135
|
end
|
@@ -161,8 +161,12 @@ module DataMapper
|
|
161
161
|
# @api private
|
162
162
|
def load_adapter(name)
|
163
163
|
require "dm-#{name}-adapter"
|
164
|
-
rescue LoadError
|
165
|
-
|
164
|
+
rescue LoadError => original_error
|
165
|
+
begin
|
166
|
+
require in_memory_adapter?(name) ? in_memory_adapter_path : legacy_path(name)
|
167
|
+
rescue LoadError
|
168
|
+
raise original_error
|
169
|
+
end
|
166
170
|
end
|
167
171
|
|
168
172
|
# Returns wether or not the given adapter name is considered an in memory adapter
|
@@ -20,18 +20,12 @@ module DataMapper
|
|
20
20
|
|
21
21
|
# @api semipublic
|
22
22
|
def self.descendants
|
23
|
-
@descendants ||=
|
23
|
+
@descendants ||= DescendantSet.new
|
24
24
|
end
|
25
25
|
|
26
26
|
# @api private
|
27
|
-
def self.inherited(
|
28
|
-
|
29
|
-
end
|
30
|
-
|
31
|
-
# @api private
|
32
|
-
def self.add_descendant(subclass)
|
33
|
-
descendants << subclass
|
34
|
-
superclass.add_descendant(subclass) if superclass.respond_to?(:add_descendant)
|
27
|
+
def self.inherited(descendant)
|
28
|
+
descendants << descendant
|
35
29
|
end
|
36
30
|
|
37
31
|
# Adapter name
|
@@ -196,7 +196,7 @@ module DataMapper
|
|
196
196
|
def through_relationship_name
|
197
197
|
if anonymous_through_model?
|
198
198
|
namespace = through_model_namespace_name.first
|
199
|
-
relationship_name =
|
199
|
+
relationship_name = DataMapper::Inflector.underscore(through_model.name.sub(/\A#{namespace.name}::/, '')).tr('/', '_')
|
200
200
|
relationship_name.pluralize.to_sym
|
201
201
|
else
|
202
202
|
options[:through]
|
@@ -55,8 +55,7 @@ module DataMapper
|
|
55
55
|
properties[property_name] || begin
|
56
56
|
# create the property within the correct repository
|
57
57
|
DataMapper.repository(repository_name) do
|
58
|
-
|
59
|
-
model.property(property_name, type, child_key_options(parent_property))
|
58
|
+
model.property(property_name, parent_property.to_child_key, child_key_options(parent_property))
|
60
59
|
end
|
61
60
|
end
|
62
61
|
end
|
@@ -181,7 +180,7 @@ module DataMapper
|
|
181
180
|
|
182
181
|
@required = options.fetch(:required, true)
|
183
182
|
@key = options.fetch(:key, false)
|
184
|
-
target_model ||=
|
183
|
+
target_model ||= DataMapper::Inflector.camelize(name)
|
185
184
|
options = { :min => @required ? 1 : 0, :max => 1 }.update(options)
|
186
185
|
super
|
187
186
|
end
|
@@ -222,7 +221,7 @@ module DataMapper
|
|
222
221
|
#
|
223
222
|
# @api private
|
224
223
|
def inverse_name
|
225
|
-
super ||
|
224
|
+
super || DataMapper::Inflector.underscore(DataMapper::Inflector.demodulize(source_model.name)).pluralize.to_sym
|
226
225
|
end
|
227
226
|
|
228
227
|
# @api private
|
@@ -110,7 +110,7 @@ module DataMapper
|
|
110
110
|
|
111
111
|
# @api semipublic
|
112
112
|
def initialize(name, target_model, source_model, options = {})
|
113
|
-
target_model ||=
|
113
|
+
target_model ||= DataMapper::Inflector.camelize(name.to_s.singularize)
|
114
114
|
options = { :min => 0, :max => source_model.n }.update(options)
|
115
115
|
super
|
116
116
|
end
|
@@ -150,7 +150,7 @@ module DataMapper
|
|
150
150
|
#
|
151
151
|
# @api private
|
152
152
|
def inverse_name
|
153
|
-
super ||
|
153
|
+
super || DataMapper::Inflector.underscore(DataMapper::Inflector.demodulize(source_model.name)).to_sym
|
154
154
|
end
|
155
155
|
|
156
156
|
# @api private
|
@@ -72,7 +72,7 @@ module DataMapper
|
|
72
72
|
# @api semipublic
|
73
73
|
def initialize(name, target_model, source_model, options = {})
|
74
74
|
klass = options.key?(:through) ? ManyToMany::Relationship : OneToMany::Relationship
|
75
|
-
target_model ||=
|
75
|
+
target_model ||= DataMapper::Inflector.camelize(name).freeze
|
76
76
|
@relationship = klass.new(name, target_model, source_model, options)
|
77
77
|
end
|
78
78
|
|