Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create executor, which simply runs the operation
- Loading branch information
Showing
3 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
module BatchApi | ||
class Processor | ||
# Public: a simple middleware that lives at the end of the internal chain | ||
# and simply executes each batch operation. | ||
class Executor | ||
|
||
# Public: initialize the middleware. | ||
def initialize(app) | ||
@app = app | ||
end | ||
|
||
# Public: execute the batch operation. | ||
def call(env) | ||
env[:op].execute | ||
end | ||
end | ||
end | ||
end |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
require 'spec_helper' | ||
require 'batch_api/processor/executor' | ||
|
||
describe BatchApi::Processor::Executor do | ||
|
||
let(:app) { stub("app", call: stub) } | ||
let(:executor) { BatchApi::Processor::Executor.new(app) } | ||
let(:result) { stub("result") } | ||
let(:op) { stub("operation", execute: result) } | ||
let(:env) { {op: op} } | ||
|
||
describe "#call" do | ||
it "executes the operation" do | ||
op.should_receive(:execute) | ||
executor.call(env) | ||
end | ||
|
||
it "returns the result" do | ||
executor.call(env).should == result | ||
end | ||
end | ||
end |
File renamed without changes.