dm-core 0.9.9 → 0.9.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. data/History.txt +10 -0
  2. data/MIT-LICENSE +1 -1
  3. data/Rakefile +4 -4
  4. data/dm-core.gemspec +14 -12
  5. data/lib/dm-core.rb +1 -1
  6. data/lib/dm-core/adapters/data_objects_adapter.rb +2 -2
  7. data/lib/dm-core/adapters/mysql_adapter.rb +1 -1
  8. data/lib/dm-core/adapters/postgres_adapter.rb +1 -1
  9. data/lib/dm-core/adapters/sqlite3_adapter.rb +1 -1
  10. data/lib/dm-core/associations/many_to_one.rb +1 -1
  11. data/lib/dm-core/associations/one_to_many.rb +18 -18
  12. data/lib/dm-core/associations/relationship.rb +9 -3
  13. data/lib/dm-core/associations/relationship_chain.rb +1 -1
  14. data/lib/dm-core/collection.rb +3 -3
  15. data/lib/dm-core/model.rb +5 -4
  16. data/lib/dm-core/resource.rb +11 -5
  17. data/lib/dm-core/version.rb +1 -1
  18. data/script/all +3 -4
  19. data/spec/integration/association_spec.rb +18 -18
  20. data/spec/integration/association_through_spec.rb +4 -4
  21. data/spec/integration/associations/many_to_many_spec.rb +9 -9
  22. data/spec/integration/associations/many_to_one_spec.rb +1 -1
  23. data/spec/integration/associations/one_to_many_spec.rb +3 -3
  24. data/spec/integration/collection_spec.rb +2 -2
  25. data/spec/integration/dependency_queue_spec.rb +1 -1
  26. data/spec/integration/model_spec.rb +1 -1
  27. data/spec/integration/mysql_adapter_spec.rb +1 -1
  28. data/spec/integration/postgres_adapter_spec.rb +16 -16
  29. data/spec/integration/property_spec.rb +10 -6
  30. data/spec/integration/query_spec.rb +4 -4
  31. data/spec/integration/repository_spec.rb +1 -1
  32. data/spec/integration/sqlite3_adapter_spec.rb +7 -7
  33. data/spec/integration/sti_spec.rb +6 -6
  34. data/spec/integration/strategic_eager_loading_spec.rb +14 -11
  35. data/spec/integration/type_spec.rb +10 -6
  36. data/spec/lib/logging_helper.rb +11 -11
  37. data/spec/spec_helper.rb +8 -4
  38. data/spec/unit/adapters/data_objects_adapter_spec.rb +9 -5
  39. data/spec/unit/adapters/in_memory_adapter_spec.rb +1 -1
  40. data/spec/unit/adapters/postgres_adapter_spec.rb +5 -5
  41. data/spec/unit/associations/many_to_many_spec.rb +2 -2
  42. data/spec/unit/associations/many_to_one_spec.rb +3 -3
  43. data/spec/unit/associations/one_to_many_spec.rb +2 -2
  44. data/spec/unit/associations/relationship_spec.rb +6 -6
  45. data/spec/unit/associations_spec.rb +21 -21
  46. data/spec/unit/identity_map_spec.rb +3 -3
  47. data/spec/unit/is_spec.rb +7 -7
  48. data/spec/unit/property_spec.rb +7 -7
  49. data/spec/unit/resource_spec.rb +12 -12
  50. data/spec/unit/transaction_spec.rb +1 -1
  51. data/tasks/dm.rb +1 -1
  52. metadata +6 -6
data/History.txt CHANGED
@@ -1,3 +1,13 @@
1
+ === 0.9.10 / 2009-01-19
2
+
3
+ * 1 major enhancement:
4
+
5
+ * Ruby 1.9.1 compatibility
6
+
7
+ * 1 minor enhancement:
8
+
9
+ * Updated Resource marshaling to be more thorough
10
+
1
11
  === 0.9.9 / 2009-01-04
2
12
 
3
13
  * 1 minor enhancement:
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2007 Sam Smoot
1
+ Copyright (c) 2007, 2008, 2009 Sam Smoot, Dan Kubb
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person
4
4
  obtaining a copy of this software and associated documentation
data/Rakefile CHANGED
@@ -9,12 +9,12 @@ require 'lib/dm-core/version'
9
9
 
10
10
  ROOT = Pathname(__FILE__).dirname.expand_path
11
11
 
12
- AUTHOR = "Sam Smoot"
13
- EMAIL = "ssmoot@gmail.com"
12
+ AUTHOR = "Dan Kubb"
13
+ EMAIL = "dan.kubb@gmail.com"
14
14
  GEM_NAME = "dm-core"
15
15
  GEM_VERSION = DataMapper::VERSION
16
- GEM_DEPENDENCIES = ["data_objects", "~>0.9.10"],
17
- ["extlib", "~>0.9.9"],
16
+ GEM_DEPENDENCIES = ["data_objects", "~>0.9.11"],
17
+ ["extlib", "~>0.9.10"],
18
18
  ["addressable", "~>2.0.1"]
19
19
 
20
20
  PROJECT_NAME = "datamapper"
data/dm-core.gemspec CHANGED
@@ -1,38 +1,40 @@
1
+ # -*- encoding: utf-8 -*-
2
+
1
3
  Gem::Specification.new do |s|
2
4
  s.name = %q{dm-core}
3
- s.version = '0.9.9'
5
+ s.version = "0.9.10"
4
6
 
5
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
6
8
  s.authors = ["Dan Kubb"]
7
- s.date = %q{2009-01-04}
8
- s.description = %q{Faster, Better, Simpler!}
9
+ s.date = %q{2009-01-19}
10
+ s.description = %q{Faster, Better, Simpler.}
9
11
  s.email = ["dan.kubb@gmail.com"]
10
12
  s.extra_rdoc_files = ["History.txt", "Manifest.txt", "README.txt"]
11
- s.files = [".autotest", "CONTRIBUTING", "FAQ", "History.txt", "MIT-LICENSE", "Manifest.txt", "QUICKLINKS", "README.txt", "Rakefile", "SPECS", "TODO", "lib/dm-core.rb", "lib/dm-core/adapters.rb", "lib/dm-core/adapters/abstract_adapter.rb", "lib/dm-core/adapters/data_objects_adapter.rb", "lib/dm-core/adapters/mysql_adapter.rb", "lib/dm-core/adapters/postgres_adapter.rb", "lib/dm-core/adapters/sqlite3_adapter.rb", "lib/dm-core/associations.rb", "lib/dm-core/associations/many_to_many.rb", "lib/dm-core/associations/many_to_one.rb", "lib/dm-core/associations/one_to_many.rb", "lib/dm-core/associations/one_to_one.rb", "lib/dm-core/associations/relationship.rb", "lib/dm-core/associations/relationship_chain.rb", "lib/dm-core/auto_migrations.rb", "lib/dm-core/collection.rb", "lib/dm-core/dependency_queue.rb", "lib/dm-core/hook.rb", "lib/dm-core/identity_map.rb", "lib/dm-core/is.rb", "lib/dm-core/logger.rb", "lib/dm-core/migrations/destructive_migrations.rb", "lib/dm-core/migrator.rb", "lib/dm-core/model.rb", "lib/dm-core/naming_conventions.rb", "lib/dm-core/property.rb", "lib/dm-core/property_set.rb", "lib/dm-core/query.rb", "lib/dm-core/repository.rb", "lib/dm-core/resource.rb", "lib/dm-core/scope.rb", "lib/dm-core/support.rb", "lib/dm-core/support/array.rb", "lib/dm-core/support/assertions.rb", "lib/dm-core/support/errors.rb", "lib/dm-core/support/kernel.rb", "lib/dm-core/support/symbol.rb", "lib/dm-core/transaction.rb", "lib/dm-core/type.rb", "lib/dm-core/type_map.rb", "lib/dm-core/types.rb", "lib/dm-core/types/boolean.rb", "lib/dm-core/types/discriminator.rb", "lib/dm-core/types/object.rb", "lib/dm-core/types/paranoid_boolean.rb", "lib/dm-core/types/paranoid_datetime.rb", "lib/dm-core/types/serial.rb", "lib/dm-core/types/text.rb", "lib/dm-core/version.rb", "script/all", "script/performance.rb", "script/profile.rb", "spec/integration/association_spec.rb", "spec/integration/association_through_spec.rb", "spec/integration/associations/many_to_many_spec.rb", "spec/integration/associations/many_to_one_spec.rb", "spec/integration/associations/one_to_many_spec.rb", "spec/integration/auto_migrations_spec.rb", "spec/integration/collection_spec.rb", "spec/integration/data_objects_adapter_spec.rb", "spec/integration/dependency_queue_spec.rb", "spec/integration/model_spec.rb", "spec/integration/mysql_adapter_spec.rb", "spec/integration/postgres_adapter_spec.rb", "spec/integration/property_spec.rb", "spec/integration/query_spec.rb", "spec/integration/repository_spec.rb", "spec/integration/resource_spec.rb", "spec/integration/sqlite3_adapter_spec.rb", "spec/integration/sti_spec.rb", "spec/integration/strategic_eager_loading_spec.rb", "spec/integration/transaction_spec.rb", "spec/integration/type_spec.rb", "spec/lib/logging_helper.rb", "spec/lib/mock_adapter.rb", "spec/lib/model_loader.rb", "spec/lib/publicize_methods.rb", "spec/models/vehicles.rb", "spec/models/zoo.rb", "spec/spec.opts", "spec/spec_helper.rb", "spec/unit/adapters/abstract_adapter_spec.rb", "spec/unit/adapters/adapter_shared_spec.rb", "spec/unit/adapters/data_objects_adapter_spec.rb", "spec/unit/adapters/postgres_adapter_spec.rb", "spec/unit/associations/many_to_many_spec.rb", "spec/unit/associations/many_to_one_spec.rb", "spec/unit/associations/one_to_many_spec.rb", "spec/unit/associations/one_to_one_spec.rb", "spec/unit/associations/relationship_spec.rb", "spec/unit/associations_spec.rb", "spec/unit/auto_migrations_spec.rb", "spec/unit/collection_spec.rb", "spec/unit/data_mapper_spec.rb", "spec/unit/identity_map_spec.rb", "spec/unit/is_spec.rb", "spec/unit/migrator_spec.rb", "spec/unit/model_spec.rb", "spec/unit/naming_conventions_spec.rb", "spec/unit/property_set_spec.rb", "spec/unit/property_spec.rb", "spec/unit/query_spec.rb", "spec/unit/repository_spec.rb", "spec/unit/resource_spec.rb", "spec/unit/scope_spec.rb", "spec/unit/transaction_spec.rb", "spec/unit/type_map_spec.rb", "spec/unit/type_spec.rb", "tasks/ci.rb", "tasks/dm.rb", "tasks/doc.rb", "tasks/gemspec.rb", "tasks/hoe.rb", "tasks/install.rb"]
13
+ s.files = [".autotest", ".gitignore", "CONTRIBUTING", "FAQ", "History.txt", "MIT-LICENSE", "Manifest.txt", "QUICKLINKS", "README.txt", "Rakefile", "SPECS", "TODO", "dm-core.gemspec", "lib/dm-core.rb", "lib/dm-core/adapters.rb", "lib/dm-core/adapters/abstract_adapter.rb", "lib/dm-core/adapters/data_objects_adapter.rb", "lib/dm-core/adapters/in_memory_adapter.rb", "lib/dm-core/adapters/mysql_adapter.rb", "lib/dm-core/adapters/postgres_adapter.rb", "lib/dm-core/adapters/sqlite3_adapter.rb", "lib/dm-core/associations.rb", "lib/dm-core/associations/many_to_many.rb", "lib/dm-core/associations/many_to_one.rb", "lib/dm-core/associations/one_to_many.rb", "lib/dm-core/associations/one_to_one.rb", "lib/dm-core/associations/relationship.rb", "lib/dm-core/associations/relationship_chain.rb", "lib/dm-core/auto_migrations.rb", "lib/dm-core/collection.rb", "lib/dm-core/dependency_queue.rb", "lib/dm-core/hook.rb", "lib/dm-core/identity_map.rb", "lib/dm-core/is.rb", "lib/dm-core/logger.rb", "lib/dm-core/migrations/destructive_migrations.rb", "lib/dm-core/migrator.rb", "lib/dm-core/model.rb", "lib/dm-core/naming_conventions.rb", "lib/dm-core/property.rb", "lib/dm-core/property_set.rb", "lib/dm-core/query.rb", "lib/dm-core/repository.rb", "lib/dm-core/resource.rb", "lib/dm-core/scope.rb", "lib/dm-core/support.rb", "lib/dm-core/support/array.rb", "lib/dm-core/support/assertions.rb", "lib/dm-core/support/errors.rb", "lib/dm-core/support/kernel.rb", "lib/dm-core/support/symbol.rb", "lib/dm-core/transaction.rb", "lib/dm-core/type.rb", "lib/dm-core/type_map.rb", "lib/dm-core/types.rb", "lib/dm-core/types/boolean.rb", "lib/dm-core/types/discriminator.rb", "lib/dm-core/types/object.rb", "lib/dm-core/types/paranoid_boolean.rb", "lib/dm-core/types/paranoid_datetime.rb", "lib/dm-core/types/serial.rb", "lib/dm-core/types/text.rb", "lib/dm-core/version.rb", "script/all", "script/performance.rb", "script/profile.rb", "spec/integration/association_spec.rb", "spec/integration/association_through_spec.rb", "spec/integration/associations/many_to_many_spec.rb", "spec/integration/associations/many_to_one_spec.rb", "spec/integration/associations/one_to_many_spec.rb", "spec/integration/auto_migrations_spec.rb", "spec/integration/collection_spec.rb", "spec/integration/data_objects_adapter_spec.rb", "spec/integration/dependency_queue_spec.rb", "spec/integration/model_spec.rb", "spec/integration/mysql_adapter_spec.rb", "spec/integration/postgres_adapter_spec.rb", "spec/integration/property_spec.rb", "spec/integration/query_spec.rb", "spec/integration/repository_spec.rb", "spec/integration/resource_spec.rb", "spec/integration/sqlite3_adapter_spec.rb", "spec/integration/sti_spec.rb", "spec/integration/strategic_eager_loading_spec.rb", "spec/integration/transaction_spec.rb", "spec/integration/type_spec.rb", "spec/lib/logging_helper.rb", "spec/lib/mock_adapter.rb", "spec/lib/model_loader.rb", "spec/lib/publicize_methods.rb", "spec/models/content.rb", "spec/models/vehicles.rb", "spec/models/zoo.rb", "spec/spec.opts", "spec/spec_helper.rb", "spec/unit/adapters/abstract_adapter_spec.rb", "spec/unit/adapters/adapter_shared_spec.rb", "spec/unit/adapters/data_objects_adapter_spec.rb", "spec/unit/adapters/in_memory_adapter_spec.rb", "spec/unit/adapters/postgres_adapter_spec.rb", "spec/unit/associations/many_to_many_spec.rb", "spec/unit/associations/many_to_one_spec.rb", "spec/unit/associations/one_to_many_spec.rb", "spec/unit/associations/one_to_one_spec.rb", "spec/unit/associations/relationship_spec.rb", "spec/unit/associations_spec.rb", "spec/unit/auto_migrations_spec.rb", "spec/unit/collection_spec.rb", "spec/unit/data_mapper_spec.rb", "spec/unit/identity_map_spec.rb", "spec/unit/is_spec.rb", "spec/unit/migrator_spec.rb", "spec/unit/model_spec.rb", "spec/unit/naming_conventions_spec.rb", "spec/unit/property_set_spec.rb", "spec/unit/property_spec.rb", "spec/unit/query_spec.rb", "spec/unit/repository_spec.rb", "spec/unit/resource_spec.rb", "spec/unit/scope_spec.rb", "spec/unit/transaction_spec.rb", "spec/unit/type_map_spec.rb", "spec/unit/type_spec.rb", "tasks/ci.rb", "tasks/dm.rb", "tasks/doc.rb", "tasks/gemspec.rb", "tasks/hoe.rb", "tasks/install.rb"]
12
14
  s.has_rdoc = true
13
15
  s.homepage = %q{http://datamapper.org}
14
16
  s.rdoc_options = ["--main", "README.txt"]
15
17
  s.require_paths = ["lib"]
16
18
  s.rubyforge_project = %q{datamapper}
17
- s.rubygems_version = %q{1.2.0}
19
+ s.rubygems_version = %q{1.3.1}
18
20
  s.summary = %q{An Object/Relational Mapper for Ruby}
19
21
 
20
22
  if s.respond_to? :specification_version then
21
23
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
22
24
  s.specification_version = 2
23
25
 
24
- if current_version >= 3 then
25
- s.add_runtime_dependency(%q<data_objects>, ["~> 0.9.10"])
26
- s.add_runtime_dependency(%q<extlib>, ["~> 0.9.9"])
26
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
27
+ s.add_runtime_dependency(%q<data_objects>, ["~> 0.9.11"])
28
+ s.add_runtime_dependency(%q<extlib>, ["~> 0.9.10"])
27
29
  s.add_runtime_dependency(%q<addressable>, ["~> 2.0.1"])
28
30
  else
29
- s.add_dependency(%q<data_objects>, ["~> 0.9.10"])
30
- s.add_dependency(%q<extlib>, ["~> 0.9.9"])
31
+ s.add_dependency(%q<data_objects>, ["~> 0.9.11"])
32
+ s.add_dependency(%q<extlib>, ["~> 0.9.10"])
31
33
  s.add_dependency(%q<addressable>, ["~> 2.0.1"])
32
34
  end
33
35
  else
34
- s.add_dependency(%q<data_objects>, ["~> 0.9.10"])
35
- s.add_dependency(%q<extlib>, ["~> 0.9.9"])
36
+ s.add_dependency(%q<data_objects>, ["~> 0.9.11"])
37
+ s.add_dependency(%q<extlib>, ["~> 0.9.10"])
36
38
  s.add_dependency(%q<addressable>, ["~> 2.0.1"])
37
39
  end
38
40
  end
data/lib/dm-core.rb CHANGED
@@ -19,7 +19,7 @@ require 'yaml'
19
19
  gem 'addressable', '~>2.0.1'
20
20
  require 'addressable/uri'
21
21
 
22
- gem 'extlib', '~>0.9.9'
22
+ gem 'extlib', '~>0.9.10'
23
23
  require 'extlib'
24
24
  require 'extlib/inflection'
25
25
 
@@ -1,4 +1,4 @@
1
- gem 'data_objects', '~>0.9.10'
1
+ gem 'data_objects', '~>0.9.11'
2
2
  require 'data_objects'
3
3
 
4
4
  module DataMapper
@@ -172,7 +172,7 @@ module DataMapper
172
172
  connection = create_connection
173
173
  return yield(connection)
174
174
  rescue => e
175
- DataMapper.logger.error(e)
175
+ DataMapper.logger.error(e.to_s)
176
176
  raise e
177
177
  ensure
178
178
  close_connection(connection) if connection
@@ -1,4 +1,4 @@
1
- gem 'do_mysql', '~>0.9.10'
1
+ gem 'do_mysql', '~>0.9.11'
2
2
  require 'do_mysql'
3
3
 
4
4
  module DataMapper
@@ -1,4 +1,4 @@
1
- gem 'do_postgres', '~>0.9.10'
1
+ gem 'do_postgres', '~>0.9.11'
2
2
  require 'do_postgres'
3
3
 
4
4
  module DataMapper
@@ -1,4 +1,4 @@
1
- gem 'do_sqlite3', '~>0.9.10'
1
+ gem 'do_sqlite3', '~>0.9.11'
2
2
  require 'do_sqlite3'
3
3
 
4
4
  module DataMapper
@@ -48,7 +48,7 @@ module DataMapper
48
48
  class Proxy
49
49
  include Assertions
50
50
 
51
- instance_methods.each { |m| undef_method m unless %w[ __id__ __send__ kind_of? respond_to? assert_kind_of should should_not instance_variable_set instance_variable_get ].include?(m.to_s) }
51
+ instance_methods.each { |m| undef_method m unless %w[ __id__ __send__ object_id kind_of? respond_to? assert_kind_of should should_not instance_variable_set instance_variable_get ].include?(m.to_s) }
52
52
 
53
53
  def replace(parent)
54
54
  @parent = parent
@@ -72,7 +72,7 @@ module DataMapper
72
72
  class Proxy
73
73
  include Assertions
74
74
 
75
- instance_methods.each { |m| undef_method m unless %w[ __id__ __send__ class kind_of? respond_to? assert_kind_of should should_not instance_variable_set instance_variable_get ].include?(m.to_s) }
75
+ instance_methods.each { |m| undef_method m unless %w[ __id__ __send__ class object_id kind_of? respond_to? assert_kind_of should should_not instance_variable_set instance_variable_get ].include?(m.to_s) }
76
76
 
77
77
  # FIXME: remove when RelationshipChain#get_children can return a Collection
78
78
  def all(query = {})
@@ -85,14 +85,14 @@ module DataMapper
85
85
  query = args.pop
86
86
  @relationship.get_children(@parent, query, :first, *args)
87
87
  else
88
- super
88
+ children.first(*args)
89
89
  end
90
90
  end
91
91
 
92
92
  def <<(resource)
93
93
  assert_mutable
94
94
  return self if !resource.new_record? && self.include?(resource)
95
- super
95
+ children << resource
96
96
  relate_resource(resource)
97
97
  self
98
98
  end
@@ -100,7 +100,7 @@ module DataMapper
100
100
  def push(*resources)
101
101
  assert_mutable
102
102
  resources.reject { |resource| !resource.new_record? && self.include?(resource) }
103
- super
103
+ children.push(*resources)
104
104
  resources.each { |resource| relate_resource(resource) }
105
105
  self
106
106
  end
@@ -108,7 +108,7 @@ module DataMapper
108
108
  def unshift(*resources)
109
109
  assert_mutable
110
110
  resources.reject { |resource| !resource.new_record? && self.include?(resource) }
111
- super
111
+ children.unshift(*resources)
112
112
  resources.each { |resource| relate_resource(resource) }
113
113
  self
114
114
  end
@@ -117,42 +117,42 @@ module DataMapper
117
117
  assert_mutable
118
118
  each { |resource| orphan_resource(resource) }
119
119
  other = other.map { |resource| resource.kind_of?(Hash) ? new_child(resource) : resource }
120
- super
120
+ children.replace(other)
121
121
  other.each { |resource| relate_resource(resource) }
122
122
  self
123
123
  end
124
124
 
125
125
  def pop
126
126
  assert_mutable
127
- orphan_resource(super)
127
+ orphan_resource(children.pop)
128
128
  end
129
129
 
130
130
  def shift
131
131
  assert_mutable
132
- orphan_resource(super)
132
+ orphan_resource(children.shift)
133
133
  end
134
134
 
135
135
  def delete(resource)
136
136
  assert_mutable
137
- orphan_resource(super)
137
+ orphan_resource(children.delete(resource))
138
138
  end
139
139
 
140
140
  def delete_at(index)
141
141
  assert_mutable
142
- orphan_resource(super)
142
+ orphan_resource(children.delete_at(index))
143
143
  end
144
144
 
145
145
  def clear
146
146
  assert_mutable
147
147
  each { |resource| orphan_resource(resource) }
148
- super
148
+ children.clear
149
149
  self
150
150
  end
151
151
 
152
152
  def build(attributes = {})
153
153
  assert_mutable
154
154
  attributes = default_attributes.merge(attributes)
155
- resource = children.respond_to?(:build) ? super(attributes) : new_child(attributes)
155
+ resource = children.respond_to?(:build) ? children.build(attributes) : new_child(attributes)
156
156
  resource
157
157
  end
158
158
 
@@ -160,7 +160,7 @@ module DataMapper
160
160
  assert_mutable
161
161
  raise UnsavedParentError, 'You cannot intialize until the parent is saved' if @parent.new_record?
162
162
  attributes = default_attributes.merge(attributes)
163
- resource = children.respond_to?(:new) ? super(attributes) : @relationship.child_model.new(attributes)
163
+ resource = children.respond_to?(:new) ? children.new(attributes) : @relationship.child_model.new(attributes)
164
164
  self << resource
165
165
  resource
166
166
  end
@@ -169,7 +169,7 @@ module DataMapper
169
169
  assert_mutable
170
170
  raise UnsavedParentError, 'You cannot create until the parent is saved' if @parent.new_record?
171
171
  attributes = default_attributes.merge(attributes)
172
- resource = children.respond_to?(:create) ? super(attributes) : @relationship.child_model.create(attributes)
172
+ resource = children.respond_to?(:create) ? children.create(attributes) : @relationship.child_model.create(attributes)
173
173
  self << resource
174
174
  resource
175
175
  end
@@ -177,25 +177,25 @@ module DataMapper
177
177
  def update(attributes = {})
178
178
  assert_mutable
179
179
  raise UnsavedParentError, 'You cannot mass-update until the parent is saved' if @parent.new_record?
180
- super
180
+ children.update(attributes)
181
181
  end
182
182
 
183
183
  def update!(attributes = {})
184
184
  assert_mutable
185
185
  raise UnsavedParentError, 'You cannot mass-update without validations until the parent is saved' if @parent.new_record?
186
- super
186
+ children.update!(attributes)
187
187
  end
188
188
 
189
189
  def destroy
190
190
  assert_mutable
191
191
  raise UnsavedParentError, 'You cannot mass-delete until the parent is saved' if @parent.new_record?
192
- super
192
+ children.destroy
193
193
  end
194
194
 
195
195
  def destroy!
196
196
  assert_mutable
197
197
  raise UnsavedParentError, 'You cannot mass-delete without validations until the parent is saved' if @parent.new_record?
198
- super
198
+ children.destroy!
199
199
  end
200
200
 
201
201
  def reload
@@ -60,14 +60,16 @@ module DataMapper
60
60
 
61
61
  # @api private
62
62
  def parent_model
63
- Class === @parent_model ? @parent_model : (Class === @child_model ? @child_model.find_const(@parent_model) : Object.find_const(@parent_model))
63
+ return @parent_model if model_defined?(@parent_model)
64
+ @parent_model = @child_model.find_const(@parent_model)
64
65
  rescue NameError
65
66
  raise NameError, "Cannot find the parent_model #{@parent_model} for #{@child_model}"
66
67
  end
67
68
 
68
69
  # @api private
69
70
  def child_model
70
- Class === @child_model ? @child_model : (Class === @parent_model ? @parent_model.find_const(@child_model) : Object.find_const(@child_model))
71
+ return @child_model if model_defined?(@child_model)
72
+ @child_model = @parent_model.find_const(@child_model)
71
73
  rescue NameError
72
74
  raise NameError, "Cannot find the child_model #{@child_model} for #{@parent_model}"
73
75
  end
@@ -130,7 +132,7 @@ module DataMapper
130
132
  # @api private
131
133
  def get_parent(child, parent = nil)
132
134
  child_value = child_key.get(child)
133
- return nil unless child_value.nitems == child_value.size
135
+ return nil if child_value.any? { |v| v.nil? }
134
136
 
135
137
  with_repository(parent || parent_model) do
136
138
  parent_identity_map = (parent || parent_model).repository.identity_map(parent_model.base_model)
@@ -190,6 +192,10 @@ module DataMapper
190
192
  assert_kind_of 'child_model', child_model, String, Class
191
193
  assert_kind_of 'parent_model', parent_model, String, Class
192
194
 
195
+ unless model_defined?(child_model) || model_defined?(parent_model)
196
+ raise 'at least one of child_model and parent_model must be a Model object'
197
+ end
198
+
193
199
  if child_properties = options[:child_key]
194
200
  assert_kind_of 'options[:child_key]', child_properties, Array
195
201
  end
@@ -60,7 +60,7 @@ module DataMapper
60
60
  # @api private
61
61
  def links
62
62
  if remote_relationship.kind_of?(RelationshipChain)
63
- remote_relationship.instance_eval { links } + [remote_relationship.instance_eval { near_relationship } ]
63
+ remote_relationship.send(:links) + [ remote_relationship.send(:near_relationship) ]
64
64
  else
65
65
  [ remote_relationship ]
66
66
  end
@@ -491,7 +491,7 @@ module DataMapper
491
491
  #
492
492
  # @api public
493
493
  def respond_to?(method, include_private = false)
494
- super || model.public_methods(false).include?(method.to_s) || relationships.has_key?(method)
494
+ super || model.public_methods(false).map { |m| m.to_s }.include?(method.to_s) || relationships.has_key?(method)
495
495
  end
496
496
 
497
497
  # TODO: add docs
@@ -537,7 +537,7 @@ module DataMapper
537
537
 
538
538
  unless block_given?
539
539
  # It can be helpful (relationship.rb: 112-13, used for SEL) to have a non-lazy Collection.
540
- block = lambda {}
540
+ block = lambda { |c| }
541
541
  end
542
542
 
543
543
  @query = query
@@ -639,7 +639,7 @@ module DataMapper
639
639
  ##
640
640
  # @api private
641
641
  def method_missing(method, *args, &block)
642
- if model.public_methods(false).include?(method.to_s)
642
+ if model.public_methods(false).map { |m| m.to_s }.include?(method.to_s)
643
643
  model.send(:with_scope, query) do
644
644
  model.send(method, *args, &block)
645
645
  end
data/lib/dm-core/model.rb CHANGED
@@ -388,8 +388,9 @@ module DataMapper
388
388
  # TODO: add docs
389
389
  # @api private
390
390
  def _load(marshalled)
391
- repository_name, attributes = Marshal.load(marshalled)
392
- repository(repository_name) { new(attributes) }
391
+ resource = allocate
392
+ Marshal.load(marshalled).each { |kv| resource.instance_variable_set(*kv) }
393
+ resource
393
394
  end
394
395
 
395
396
  def typecast_key(key)
@@ -442,7 +443,7 @@ module DataMapper
442
443
  end
443
444
  EOS
444
445
 
445
- if property.primitive == TrueClass && !instance_methods.include?(property.name.to_s)
446
+ if property.primitive == TrueClass && !instance_methods.map { |m| m.to_s }.include?(property.name.to_s)
446
447
  class_eval <<-EOS, __FILE__, __LINE__
447
448
  #{property.reader_visibility}
448
449
  alias #{property.name} #{property.getter}
@@ -452,7 +453,7 @@ module DataMapper
452
453
 
453
454
  # defines the setter for the property
454
455
  def create_property_setter(property)
455
- unless instance_methods.include?("#{property.name}=")
456
+ unless instance_methods.map { |m| m.to_s }.include?("#{property.name}=")
456
457
  class_eval <<-EOS, __FILE__, __LINE__
457
458
  #{property.writer_visibility}
458
459
  def #{property.name}=(value)
@@ -531,14 +531,20 @@ module DataMapper
531
531
  # TODO: add docs
532
532
  # @api private
533
533
  def _dump(*)
534
- repository_name = repository.name
535
- attributes = {}
534
+ ivars = {}
536
535
 
537
- model.properties(repository_name).slice(*loaded_attributes).compact.each do |property|
538
- attributes[property.name] = property.get(self) if property.writer_visibility == :public
536
+ # dump all the loaded properties
537
+ properties.each do |property|
538
+ next unless attribute_loaded?(property.name)
539
+ ivars[property.instance_variable_name] = property.get!(self)
540
+ end
541
+
542
+ # dump ivars used internally
543
+ %w[ @new_record @original_values @readonly @repository ].each do |name|
544
+ ivars[name] = instance_variable_get(name)
539
545
  end
540
546
 
541
- Marshal.dump([ repository_name, attributes ])
547
+ Marshal.dump(ivars)
542
548
  end
543
549
 
544
550
  protected
@@ -1,3 +1,3 @@
1
1
  module DataMapper
2
- VERSION = '0.9.9' unless defined?(DataMapper::VERSION)
2
+ VERSION = '0.9.10' unless defined?(DataMapper::VERSION)
3
3
  end
data/script/all CHANGED
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env sh
2
- rake spec:unit
3
- ADAPTER=sqlite3 rake spec:integration
4
- ADAPTER=mysql rake spec:integration
5
- ADAPTER=postgres rake spec:integration
2
+ ADAPTER=sqlite3 rake spec
3
+ ADAPTER=mysql rake spec
4
+ ADAPTER=postgres rake spec
@@ -9,7 +9,7 @@ if HAS_SQLITE3
9
9
  FileUtils.touch(db2)
10
10
  DataMapper.setup(:custom_db1, "sqlite3://#{db1}")
11
11
  DataMapper.setup(:custom_db2, "sqlite3://#{db2}")
12
- class CustomParent
12
+ class ::CustomParent
13
13
  include DataMapper::Resource
14
14
  def self.default_repository_name
15
15
  :custom_db1
@@ -20,7 +20,7 @@ if HAS_SQLITE3
20
20
  has n, :custom_childs
21
21
  end
22
22
  end
23
- class CustomChild
23
+ class ::CustomChild
24
24
  include DataMapper::Resource
25
25
  def self.default_repository_name
26
26
  :custom_db2
@@ -70,7 +70,7 @@ end
70
70
 
71
71
  if ADAPTER
72
72
  repository(ADAPTER) do
73
- class Machine
73
+ class ::Machine
74
74
  include DataMapper::Resource
75
75
 
76
76
  def self.default_repository_name
@@ -84,7 +84,7 @@ if ADAPTER
84
84
  has n, :fussy_areas, :class_name => 'Area', :rating.gte => 3, :type => 'particular'
85
85
  end
86
86
 
87
- class Area
87
+ class ::Area
88
88
  include DataMapper::Resource
89
89
 
90
90
  def self.default_repository_name
@@ -99,7 +99,7 @@ if ADAPTER
99
99
  belongs_to :machine
100
100
  end
101
101
 
102
- class Pie
102
+ class ::Pie
103
103
  include DataMapper::Resource
104
104
 
105
105
  def self.default_repository_name
@@ -112,7 +112,7 @@ if ADAPTER
112
112
  belongs_to :sky
113
113
  end
114
114
 
115
- class Sky
115
+ class ::Sky
116
116
  include DataMapper::Resource
117
117
 
118
118
  def self.default_repository_name
@@ -125,7 +125,7 @@ if ADAPTER
125
125
  has 1, :pie
126
126
  end
127
127
 
128
- class Ultrahost
128
+ class ::Ultrahost
129
129
  include DataMapper::Resource
130
130
 
131
131
  def self.default_repository_name
@@ -138,7 +138,7 @@ if ADAPTER
138
138
  has n, :ultraslices, :order => [:id.desc]
139
139
  end
140
140
 
141
- class Ultraslice
141
+ class ::Ultraslice
142
142
  include DataMapper::Resource
143
143
 
144
144
  def self.default_repository_name
@@ -151,7 +151,7 @@ if ADAPTER
151
151
  belongs_to :ultrahost
152
152
  end
153
153
 
154
- class Node
154
+ class ::Node
155
155
  include DataMapper::Resource
156
156
 
157
157
  def self.default_repository_name
@@ -165,7 +165,7 @@ if ADAPTER
165
165
  belongs_to :parent, :class_name => 'Node', :child_key => [ :parent_id ]
166
166
  end
167
167
 
168
- class MadeUpThing
168
+ class ::MadeUpThing
169
169
  include DataMapper::Resource
170
170
 
171
171
  def self.default_repository_name
@@ -178,7 +178,7 @@ if ADAPTER
178
178
  belongs_to :machine
179
179
  end
180
180
 
181
- module Models
181
+ module ::Models
182
182
  class Project
183
183
  include DataMapper::Resource
184
184
 
@@ -220,7 +220,7 @@ if ADAPTER
220
220
  end
221
221
  end
222
222
 
223
- class Galaxy
223
+ class ::Galaxy
224
224
  include DataMapper::Resource
225
225
 
226
226
  def self.default_repository_name
@@ -231,7 +231,7 @@ if ADAPTER
231
231
  property :size, Float, :key => true, :precision => 15, :scale => 6
232
232
  end
233
233
 
234
- class Star
234
+ class ::Star
235
235
  include DataMapper::Resource
236
236
 
237
237
  def self.default_repository_name
@@ -303,7 +303,7 @@ if ADAPTER
303
303
  end
304
304
 
305
305
  it 'should create the foreign key property immediately' do
306
- class Duck
306
+ class ::Duck
307
307
  include DataMapper::Resource
308
308
  property :id, Serial
309
309
  belongs_to :sky
@@ -334,7 +334,7 @@ if ADAPTER
334
334
 
335
335
  it '#belongs_to with namespaced models' do
336
336
  repository(ADAPTER) do
337
- module FlightlessBirds
337
+ module ::FlightlessBirds
338
338
  class Ostrich
339
339
  include DataMapper::Resource
340
340
  property :id, Serial
@@ -728,7 +728,7 @@ if ADAPTER
728
728
  describe 'through-associations' do
729
729
  before :all do
730
730
  repository(ADAPTER) do
731
- module Sweets
731
+ module ::Sweets
732
732
  class Shop
733
733
  include DataMapper::Resource
734
734
  def self.default_repository_name
@@ -1219,7 +1219,7 @@ if ADAPTER
1219
1219
  if false # Many to many not yet implemented
1220
1220
  describe "many to many associations" do
1221
1221
  before(:all) do
1222
- class RightItem
1222
+ class ::RightItem
1223
1223
  include DataMapper::Resource
1224
1224
 
1225
1225
  def self.default_repository_name
@@ -1232,7 +1232,7 @@ if ADAPTER
1232
1232
  has n..n, :left_items
1233
1233
  end
1234
1234
 
1235
- class LeftItem
1235
+ class ::LeftItem
1236
1236
  include DataMapper::Resource
1237
1237
 
1238
1238
  def self.default_repository_name