Class: Tarantool::EMDB::ConcatterReplace
- Inherits:
-
Object
- Object
- Tarantool::EMDB::ConcatterReplace
- Defined in:
- lib/tarantool/em_db.rb
Instance Method Summary collapse
- #call(array) ⇒ Object
-
#initialize(count, feed) ⇒ ConcatterReplace
constructor
A new instance of ConcatterReplace.
Constructor Details
#initialize(count, feed) ⇒ ConcatterReplace
Returns a new instance of ConcatterReplace.
168 169 170 171 172 |
# File 'lib/tarantool/em_db.rb', line 168 def initialize(count, feed) @result = [] @count = count @feed = feed end |
Instance Method Details
#call(array) ⇒ Object
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
# File 'lib/tarantool/em_db.rb', line 173 def call(array) if @count > 0 case array when Array @result.concat array when ::Tarantool::TupleDoesntExists @result << array when Exception @result = array @count = 1 else @result << array end if (@count -= 1) == 0 if Exception === @result @feed.call @result elsif @result.all?{|r| ::Tarantool::TupleDoesntExists === r} @feed.call @result.first else @result.delete_if{|r| ::Tarantool::TupleDoesntExists === r} if Integer === @result.first @feed.call @result.inject(0){|s, i| s + i} else @feed.call @result end end end end end |