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.



93
94
95
96
# File 'lib/tarantool16/dumb_db.rb', line 93

def initialize
  @r = UNDEF
  @cb = nil
end

Instance Method Details

#set(r) ⇒ Object



117
118
119
120
121
122
123
# File 'lib/tarantool16/dumb_db.rb', line 117

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

#then(cb) ⇒ Object



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

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



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

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