Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Use ActiveSupport DescendantsTracker

  • Loading branch information...
commit 925b5bab982a347c87786c0f027f45229bb550d9 1 parent 34d121b
Brian Ryckbost bryckbost authored
2  UPGRADES
View
@@ -2,6 +2,8 @@
* [attribute]_before_typecast should become [attribute]_before_type_cast (note the extra _)
* Change validates_exclusion_of :within option to :in
* Change validates_inclusion_of :within option to :in
+ * descendants now returns all descendants use direct_descendants for just children
+ * Switch validate_on_create and validate_on_update use validate :on => :create syntax
0.7.6 => 0.8
* Proxy#owner has been removed in favor of Proxy#proxy_owner
2  lib/mongo_mapper/document.rb
View
@@ -13,6 +13,7 @@ def self.included(model)
include ActiveModel::Naming
include ActiveModel::Serialization
include ActiveModel::Serializers::JSON
+ include ActiveSupport::DescendantsTracker
extend ActiveModel::Translation
plugin Plugins::Document
@@ -20,7 +21,6 @@ def self.included(model)
plugin Plugins::Associations
plugin Plugins::Caching
plugin Plugins::Clone
- plugin Plugins::Descendants
plugin Plugins::DynamicQuerying
plugin Plugins::Equality
plugin Plugins::Inspect
2  lib/mongo_mapper/embedded_document.rb
View
@@ -13,13 +13,13 @@ def self.included(model)
include ActiveModel::Naming
include ActiveModel::Serialization
include ActiveModel::Serializers::JSON
+ include ActiveSupport::DescendantsTracker
extend ActiveModel::Translation
plugin Plugins::EmbeddedDocument
plugin Plugins::Associations
plugin Plugins::Caching
plugin Plugins::Clone
- plugin Plugins::Descendants
plugin Plugins::Equality
plugin Plugins::Inspect
plugin Plugins::Keys
17 lib/mongo_mapper/plugins/descendants.rb
View
@@ -1,17 +0,0 @@
-# encoding: UTF-8
-module MongoMapper
- module Plugins
- module Descendants
- module ClassMethods
- def inherited(descendant)
- descendants << descendant
- super
- end
-
- def descendants
- @descendants ||= []
- end
- end
- end
- end
-end
4 test/unit/test_embedded_document.rb
View
@@ -207,7 +207,9 @@ class ::OtherChild < ::Parent
end
should "be recorded" do
- Grandparent.descendants.should == [Parent]
+ Grandparent.direct_descendants.should == [Parent]
+ Grandparent.descendants.to_set.should == [Parent, Child, OtherChild].to_set
+
Parent.descendants.should == [Child, OtherChild]
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.