Created
November 4, 2008 18:52
-
-
Save dbussink/22183 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/dm-core/collection.rb b/lib/dm-core/collection.rb | |
index b58b6fe..3b9fdc3 100644 | |
--- a/lib/dm-core/collection.rb | |
+++ b/lib/dm-core/collection.rb | |
@@ -166,6 +166,8 @@ module DataMapper | |
if loaded? && args.empty? | |
return relate_resource(super) | |
+ elsif !loaded? && !args.last.respond_to?(:merge) && lazy_possible?(head, *args) | |
+ return head.first(*args) | |
end | |
limit = if args.first.kind_of?(Integer) | |
@@ -205,6 +207,8 @@ module DataMapper | |
def last(*args) | |
if loaded? && args.empty? | |
return relate_resource(super) | |
+ elsif !loaded? && !args.last.respond_to?(:merge) && lazy_possible?(tail, *args) | |
+ return tail.last(*args) | |
end | |
limit = if args.first.kind_of?(Integer) | |
@@ -289,6 +294,9 @@ module DataMapper | |
# @api public | |
def slice!(*args) | |
orphaned = super | |
+ | |
+ # Workaround for Ruby <= 1.8.6 | |
+ compact! | |
if orphaned.respond_to?(:each) | |
orphaned.each { |r| orphan_resource(r) } | |
else | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment