Commit 3b460ccd812742bebed6b611bc1701589163dee9

Authored by Andrew Kane
1 parent 6e62e029

Fixed offset with no arguments

Showing 1 changed file with 9 additions and 2 deletions   Show diff stats
lib/searchkick/relation.rb
1 1 module Searchkick
2 2 class Relation
  3 + NO_DEFAULT_VALUE = Object.new
  4 +
3 5 # note: modifying body directly is not supported
4 6 # and has no impact on query after being executed
5 7 # TODO freeze body object?
... ... @@ -38,8 +40,13 @@ module Searchkick
38 40 self
39 41 end
40 42  
41   - def offset(value)
42   - clone.offset!(value)
  43 + def offset(value = NO_DEFAULT_VALUE)
  44 + # TODO remove in Searchkick 6
  45 + if value == NO_DEFAULT_VALUE
  46 + private_execute.offset
  47 + else
  48 + clone.offset!(value)
  49 + end
43 50 end
44 51  
45 52 def offset!(value)
... ...