Skip to content

Commit

Permalink
Add max scan options
Browse files Browse the repository at this point in the history
  • Loading branch information
durran committed Nov 1, 2011
1 parent 3cd3e6f commit 0ee40c1
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/origin/optional.rb
Expand Up @@ -2,6 +2,7 @@
require "origin/optional/batch_size"
require "origin/optional/hint"
require "origin/optional/limit"
require "origin/optional/max_scan"
require "origin/optional/no_timeout"
require "origin/optional/only"
require "origin/optional/read"
Expand All @@ -11,14 +12,14 @@
require "origin/optional/snapshot"
require "origin/optional/without"

# require "origin/optional/max_scan"
# require "origin/optional/transformer"

module Origin
module Optional
include BatchSize
include Hint
include Limit
include MaxScan
include NoTimeout
include Only
include Read
Expand Down
11 changes: 11 additions & 0 deletions lib/origin/optional/max_scan.rb
@@ -0,0 +1,11 @@
# encoding: utf-8
module Origin
module Optional
module MaxScan

def max_scan(value = nil)
option(value) { |options| options.store(:max_scan, value) }
end
end
end
end
64 changes: 64 additions & 0 deletions spec/origin/optional/max_scan_spec.rb
@@ -0,0 +1,64 @@
require "spec_helper"

describe Origin::Optional::MaxScan do

let(:query) do
Origin::Query.new
end

describe "#max_scan" do

context "when provided no options" do

let(:selection) do
query.max_scan
end

it "does not add any options" do
selection.options.should eq({})
end

it "returns the query" do
selection.should eq(query)
end

it "returns a cloned query" do
selection.should_not equal(query)
end
end

context "when provided nil" do

let(:selection) do
query.max_scan(nil)
end

it "does not add any options" do
selection.options.should eq({})
end

it "returns the query" do
selection.should eq(query)
end

it "returns a cloned query" do
selection.should_not equal(query)
end
end

context "when provided arguments" do

let(:selection) do
query.max_scan(500)
end

it "adds the field options" do
selection.options.should eq({ :max_scan => 500 })
end

it "returns a cloned query" do
selection.should_not equal(query)
end
end
end
end

0 comments on commit 0ee40c1

Please sign in to comment.