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.
Files changed (42) hide show
  1. data/.gitignore +1 -0
  2. data/Gemfile +19 -20
  3. data/Rakefile +1 -1
  4. data/VERSION +1 -1
  5. data/dm-core.gemspec +15 -12
  6. data/lib/dm-core.rb +23 -14
  7. data/lib/dm-core/adapters.rb +7 -3
  8. data/lib/dm-core/adapters/abstract_adapter.rb +3 -9
  9. data/lib/dm-core/associations/many_to_many.rb +1 -1
  10. data/lib/dm-core/associations/many_to_one.rb +3 -4
  11. data/lib/dm-core/associations/one_to_many.rb +2 -2
  12. data/lib/dm-core/associations/one_to_one.rb +1 -1
  13. data/lib/dm-core/collection.rb +4 -6
  14. data/lib/dm-core/model.rb +22 -32
  15. data/lib/dm-core/model/property.rb +15 -39
  16. data/lib/dm-core/property.rb +75 -87
  17. data/lib/dm-core/property/discriminator.rb +3 -3
  18. data/lib/dm-core/property/lookup.rb +42 -0
  19. data/lib/dm-core/property/object.rb +5 -0
  20. data/lib/dm-core/property/serial.rb +6 -1
  21. data/lib/dm-core/query/conditions/comparison.rb +3 -3
  22. data/lib/dm-core/query/conditions/operation.rb +3 -3
  23. data/lib/dm-core/resource.rb +2 -2
  24. data/lib/dm-core/resource/state/dirty.rb +2 -2
  25. data/lib/dm-core/spec/lib/spec_helper.rb +11 -3
  26. data/lib/dm-core/spec/setup.rb +2 -2
  27. data/{spec/public/shared/property_shared_spec.rb → lib/dm-core/spec/shared/public/property_spec.rb} +51 -20
  28. data/{spec/semipublic/shared/property_shared_spec.rb → lib/dm-core/spec/shared/semipublic/property_spec.rb} +22 -26
  29. data/lib/dm-core/support/descendant_set.rb +84 -0
  30. data/lib/dm-core/support/naming_conventions.rb +8 -8
  31. data/lib/dm-core/types/discriminator.rb +2 -2
  32. data/spec/public/associations/many_to_one_with_custom_fk_spec.rb +49 -0
  33. data/spec/public/finalize_spec.rb +42 -11
  34. data/spec/public/property/discriminator_spec.rb +6 -6
  35. data/spec/semipublic/adapters/abstract_adapter_spec.rb +1 -1
  36. data/spec/semipublic/property/lookup_spec.rb +26 -0
  37. data/spec/semipublic/property_spec.rb +43 -0
  38. data/spec/semipublic/resource/state/dirty_spec.rb +4 -2
  39. data/spec/support/{types → properties}/huge_integer.rb +5 -5
  40. data/tasks/local_gemfile.rake +5 -7
  41. metadata +15 -19
  42. data/lib/dm-core/model/descendant_set.rb +0 -81
@@ -1,81 +0,0 @@
1
- module DataMapper
2
- module Model
3
- class DescendantSet
4
- include Enumerable
5
-
6
- # Append a model as a descendant
7
- #
8
- # @param [Model] model
9
- # the descendant model
10
- #
11
- # @return [DescendantSet]
12
- # self
13
- #
14
- # @api private
15
- def <<(model)
16
- @descendants << model unless @descendants.include?(model)
17
- @ancestors << model if @ancestors
18
- self
19
- end
20
-
21
- # Iterate over each descendant
22
- #
23
- # @yield [model]
24
- # iterate over each descendant
25
- # @yieldparam [Model] model
26
- # the descendant model
27
- #
28
- # @return [DescendantSet]
29
- # self
30
- #
31
- # @api private
32
- def each
33
- @descendants.each { |model| yield model }
34
- self
35
- end
36
-
37
- # Remove a descendant
38
- #
39
- # Also removed the descendant from the ancestors.
40
- #
41
- # @param [Model] model
42
- # the model to remove
43
- #
44
- # @return [Model, nil]
45
- # the model is return if it is a descendant
46
- #
47
- # @api private
48
- def delete(model)
49
- @ancestors.delete(model) if @ancestors
50
- @descendants.delete(model)
51
- end
52
-
53
- # Return an Array representation of descendants
54
- #
55
- # @return [Array]
56
- # the descendants
57
- #
58
- # @api private
59
- def to_ary
60
- @descendants.dup
61
- end
62
-
63
- private
64
-
65
- # Initialize a DescendantSet instance
66
- #
67
- # @param [Model] model
68
- # the base model
69
- # @param [DescendantSet] ancestors
70
- # the ancestors to notify when a descendant is added
71
- #
72
- # @api private
73
- def initialize(model = nil, ancestors = nil)
74
- @descendants = []
75
- @ancestors = ancestors
76
-
77
- @descendants << model if model
78
- end
79
- end
80
- end
81
- end