Skip to content

Commit

Permalink
more friendly #call
Browse files Browse the repository at this point in the history
  • Loading branch information
prepor committed May 6, 2012
1 parent d62cc6d commit 0d62510
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
tarantool (0.2.2)
tarantool (0.2.3)
activemodel (>= 3.1, < 4.0)
iproto (>= 0.2)

Expand Down
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -111,6 +111,7 @@ in the tuple stored by Tarantool. By default, the primary key is field 0.

# TODO

# .to_config
* `#first`, `#all` without keys, batches requests via box.select_range
* `#where` chains
* admin-socket protocol
Expand Down
2 changes: 1 addition & 1 deletion lib/tarantool/record.rb
Expand Up @@ -19,7 +19,7 @@ def each(&blk)
end

def call(proc_name, *args)
to_records record.space.call(proc_name: proc_name, args: args, return_tuple: true).tuples
to_records record.space.call(proc_name, *args, return_tuple: true).tuples
end

def limit(limit)
Expand Down
4 changes: 2 additions & 2 deletions lib/tarantool/requests/call.rb
Expand Up @@ -6,8 +6,8 @@ class Call < Request
attr_reader :flags, :proc_name, :tuple
def parse_args
@flags = params[:return_tuple] ? 1 : 0
@proc_name = params[:proc_name]
@tuple = params[:args] || []
@proc_name = args.shift
@tuple = args.map(&:to_s)
end

def make_body
Expand Down
2 changes: 1 addition & 1 deletion spec/helpers/truncate.rb
@@ -1,7 +1,7 @@
module Helpers
module Truncate
def teardown
while (res = space.call(proc_name: 'box.select_range', args: [space.space_no.to_s, '0', '100'], return_tuple: true)) && res.tuples.size > 0
while (res = space.call('box.select_range', space.space_no, 0, 100, return_tuple: true)) && res.tuples.size > 0
res.tuples.each do |k, *_|
space.delete key: k
end
Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Expand Up @@ -11,7 +11,7 @@

require 'tarantool'

TARANTOOL_CONFIG = { host: '127.0.0.1', port: 33013, type: :block }
TARANTOOL_CONFIG = { host: 'localhost', port: 33013, type: :block }

DB = Tarantool.new TARANTOOL_CONFIG

Expand Down
2 changes: 1 addition & 1 deletion spec/tarantool/record_spec.rb
Expand Up @@ -248,7 +248,7 @@ def self.name # For naming
end

describe "call" do
let(:res) { user.class.select.call('box.select_range', '0','0', '2')}
let(:res) { user.class.select.call('box.select_range', 0, 0, 2)}
before do
user_class.create login: 'prepor', name: 'Andrew', email: 'ceo@prepor.ru'
user_class.create login: 'petro', name: 'Petr', email: 'petro@gmail.com'
Expand Down
4 changes: 2 additions & 2 deletions spec/tarantool/request_spec.rb
Expand Up @@ -61,14 +61,14 @@ def space

describe "call" do
it "should call lua proc" do
res = space.call proc_name: 'box.pack', args: ['i', '100'], return_tuple: true
res = space.call 'box.pack', 'i', '100', return_tuple: true
res.tuple[0].to_i.must_equal 100
end

it "should return batches via select_range" do
space.insert 100, 'привет'
space.insert 101, 'hi'
res = space.call proc_name: 'box.select_range', args: ['1', '0', '100'], return_tuple: true
res = space.call 'box.select_range', '1', '0', '100', return_tuple: true
res.tuples.size.must_equal 2
end
end
Expand Down

0 comments on commit 0d62510

Please sign in to comment.