mongoid 1.2.8 → 1.2.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. data/Rakefile +1 -1
  2. data/VERSION +1 -1
  3. data/lib/mongoid.rb +2 -3
  4. data/lib/mongoid/associations.rb +5 -3
  5. data/lib/mongoid/associations/belongs_to_related.rb +6 -9
  6. data/lib/mongoid/associations/has_many.rb +2 -0
  7. data/lib/mongoid/associations/has_many_related.rb +10 -0
  8. data/lib/mongoid/attributes.rb +6 -1
  9. data/lib/mongoid/commands.rb +2 -10
  10. data/lib/mongoid/components.rb +11 -12
  11. data/lib/mongoid/contexts/enumerable.rb +21 -11
  12. data/lib/mongoid/contexts/mongo.rb +40 -1
  13. data/lib/mongoid/criteria.rb +3 -29
  14. data/lib/mongoid/criterion/inclusion.rb +2 -1
  15. data/lib/mongoid/document.rb +5 -6
  16. data/lib/mongoid/extensions.rb +10 -0
  17. data/lib/mongoid/extensions/big_decimal/conversions.rb +19 -0
  18. data/lib/mongoid/extensions/binary/conversions.rb +17 -0
  19. data/lib/mongoid/{caching.rb → extras.rb} +26 -3
  20. data/lib/mongoid/field.rb +20 -7
  21. data/lib/mongoid/finders.rb +10 -80
  22. data/mongoid.gemspec +15 -13
  23. data/spec/integration/mongoid/document_spec.rb +1 -1
  24. data/spec/models/person.rb +1 -0
  25. data/spec/unit/mongoid/associations/belongs_to_related_spec.rb +4 -0
  26. data/spec/unit/mongoid/associations/has_many_related_spec.rb +42 -13
  27. data/spec/unit/mongoid/associations/has_many_spec.rb +12 -7
  28. data/spec/unit/mongoid/associations_spec.rb +16 -0
  29. data/spec/unit/mongoid/attributes_spec.rb +23 -0
  30. data/spec/unit/mongoid/commands/destroy_spec.rb +3 -0
  31. data/spec/unit/mongoid/commands_spec.rb +4 -11
  32. data/spec/unit/mongoid/contexts/enumerable_spec.rb +16 -0
  33. data/spec/unit/mongoid/contexts/mongo_spec.rb +96 -0
  34. data/spec/unit/mongoid/criteria_spec.rb +11 -4
  35. data/spec/unit/mongoid/document_spec.rb +11 -0
  36. data/spec/unit/mongoid/extensions/big_decimal/conversions_spec.rb +22 -0
  37. data/spec/unit/mongoid/extensions/binary/conversions_spec.rb +22 -0
  38. data/spec/unit/mongoid/{enslavement_spec.rb → extras_spec.rb} +55 -2
  39. data/spec/unit/mongoid/field_spec.rb +62 -0
  40. data/spec/unit/mongoid/finders_spec.rb +36 -0
  41. metadata +69 -37
  42. data/HISTORY +0 -342
  43. data/lib/mongoid/enslavement.rb +0 -38
  44. data/spec/unit/mongoid/caching_spec.rb +0 -63
@@ -1,38 +0,0 @@
1
- # encoding: utf-8
2
- module Mongoid #:nodoc:
3
- module Enslavement #:nodoc:
4
- def self.included(base)
5
- base.class_eval do
6
- extend ClassMethods
7
- class_inheritable_accessor :enslaved
8
- self.enslaved = false
9
-
10
- delegate :enslaved?, :to => "self.class"
11
- end
12
- end
13
-
14
- module ClassMethods #:nodoc
15
- # Set whether or not this documents read operations should delegate to
16
- # the slave database by default.
17
- #
18
- # Example:
19
- #
20
- # class Person
21
- # include Mongoid::Document
22
- # enslave
23
- # end
24
- def enslave
25
- self.enslaved = true
26
- end
27
-
28
- # Determines if the class is enslaved or not.
29
- #
30
- # Returns:
31
- #
32
- # True if enslaved, false if not.
33
- def enslaved?
34
- self.enslaved == true
35
- end
36
- end
37
- end
38
- end
@@ -1,63 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Mongoid::Caching do
4
-
5
- before do
6
- @klass = Class.new do
7
- include Mongoid::Caching
8
- end
9
- end
10
-
11
- describe ".cache" do
12
-
13
- before do
14
- @klass.cache
15
- end
16
-
17
- it "sets the cached boolean on the class" do
18
- @klass.cached.should be_true
19
- end
20
-
21
- end
22
-
23
- describe ".cached" do
24
-
25
- it "defaults to false" do
26
- @klass.cached.should be_false
27
- end
28
- end
29
-
30
- describe ".cached?" do
31
-
32
- context "when the class is cached" do
33
-
34
- before do
35
- @klass.cache
36
- end
37
-
38
- it "returns true" do
39
- @klass.should be_cached
40
- end
41
- end
42
-
43
- context "when the class is not cached" do
44
-
45
- it "returns false" do
46
- @klass.should_not be_cached
47
- end
48
- end
49
-
50
- end
51
-
52
- describe "#cached?" do
53
-
54
- before do
55
- @klass.cache
56
- @doc = @klass.new
57
- end
58
-
59
- it "returns the class cached? value" do
60
- @doc.should be_cached
61
- end
62
- end
63
- end