Module: RDB::Dumper
Instance Method Summary
collapse
#accept_key?, #end_database, #end_hash, #end_list, #end_rdb, #end_set, #end_sortedset, #hset, #pexpireat, #rpush, #sadd, #set, #skip_object, #start_database, #start_hash, #start_list, #start_rdb, #start_set, #start_sortedset, #zadd
Instance Method Details
#<<(buffer) ⇒ Object
12
13
14
|
# File 'lib/rdb/dumper.rb', line 12
def <<(buffer)
@output << buffer unless @output.nil?; nil
end
|
#dump ⇒ Object
28
29
30
31
32
33
34
35
|
# File 'lib/rdb/dumper.rb', line 28
def dump
raise RuntimeException, 'Output stream already opened' if @output
with_streams do |input, output|
@output = output
Reader.read(input, callbacks: self)
end
end
|
#initialize(source, destination, options = {}) ⇒ Object
5
6
7
8
9
10
|
# File 'lib/rdb/dumper.rb', line 5
def initialize(source, destination, options = {})
@source = source
@destination = destination
@options = options
@output = nil
end
|
#with_streams(&block) ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/rdb/dumper.rb', line 16
def with_streams(&block)
input = open(@source, 'rb') unless @source.kind_of? IO
output = open(@destination, 'wb') unless @destination.kind_of? IO
begin
block.call(input, output)
ensure
input.close
output.close
end
end
|