Class: Tarantool16::DumbDB::SchemaFuture

Inherits:
Object
  • Object
show all
Defined in:
lib/tarantool16/dumb_db.rb

Constant Summary collapse

UNDEF =
Object.new.freeze

Instance Method Summary collapse

Constructor Details

#initializeSchemaFuture

Returns a new instance of SchemaFuture.



84
85
86
87
# File 'lib/tarantool16/dumb_db.rb', line 84

def initialize
  @r = UNDEF
  @cb = nil
end

Instance Method Details

#set(r) ⇒ Object



108
109
110
111
112
113
114
# File 'lib/tarantool16/dumb_db.rb', line 108

def set(r)
  @r = r
  if cb = @cb
    @cb = nil
    cb.call(r)
  end
end

#then(cb) ⇒ Object



88
89
90
91
92
93
94
95
96
# File 'lib/tarantool16/dumb_db.rb', line 88

def then(cb)
  unless @r.equal? UNDEF
    return cb.call(@r)
  end
  if @cb
    raise "Blocking future accepts only 1 callback"
  end
  @cb = cb
end

#then_blkObject



98
99
100
101
102
103
104
105
106
# File 'lib/tarantool16/dumb_db.rb', line 98

def then_blk
  unless @r.equal? UNDEF
    return yield @r
  end
  if @cb
    raise "Blocking future accepts only 1 callback"
  end
  @cb = lambda{|r| yield r}
end