Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

skip and limit now default to nil which makes using offset easier and…

… works the same otherwise.
  • Loading branch information...
commit 74107966b2ef27f6397dd3eb8b1de93c9c8d337c 1 parent 8316312
John Nunemaker jnunemaker authored
Showing with 12 additions and 8 deletions.
  1. +4 −4 lib/plucky/query.rb
  2. +8 −4 test/test_query.rb
8 lib/plucky/query.rb
View
@@ -30,8 +30,8 @@ def filter(hash={})
self
end
- def limit(count=0)
- @options[:limit] = count.to_i
+ def limit(count=nil)
+ @options[:limit] = count.nil? ? nil : count.to_i
self
end
@@ -40,8 +40,8 @@ def reverse
self
end
- def skip(count=0)
- @options[:skip] = count.to_i
+ def skip(count=nil)
+ @options[:skip] = count.nil? ? nil : count.to_i
self
end
12 test/test_query.rb
View
@@ -207,6 +207,10 @@ class QueryTest < Test::Unit::TestCase
should "override existing skip" do
Query.new(:skip => 5).skip(10).options[:skip].should == 10
end
+
+ should "return nil for nil" do
+ Query.new.skip.options[:skip].should be_nil
+ end
end
context "#sort" do
@@ -304,8 +308,8 @@ class QueryTest < Test::Unit::TestCase
end
context "skip option" do
- should "default to 0" do
- Query.new({}).options[:skip].should == 0
+ should "default to nil" do
+ Query.new({}).options[:skip].should == nil
end
should "use skip provided" do
@@ -322,8 +326,8 @@ class QueryTest < Test::Unit::TestCase
end
context "limit option" do
- should "default to 0" do
- Query.new({}).options[:limit].should == 0
+ should "default to nil" do
+ Query.new({}).options[:limit].should == nil
end
should "use limit provided" do
Please sign in to comment.
Something went wrong with that request. Please try again.