Class: Tarantool::EMDB::Concatter
- Inherits:
-
Object
- Object
- Tarantool::EMDB::Concatter
- Defined in:
- lib/tarantool/em_db.rb
Instance Method Summary collapse
- #call(array) ⇒ Object
-
#initialize(count, feed) ⇒ Concatter
constructor
A new instance of Concatter.
Constructor Details
#initialize(count, feed) ⇒ Concatter
Returns a new instance of Concatter.
158 159 160 161 162 |
# File 'lib/tarantool/em_db.rb', line 158 def initialize(count, feed) @result = [] @count = count @feed = feed end |
Instance Method Details
#call(array) ⇒ Object
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
# File 'lib/tarantool/em_db.rb', line 163 def call(array) if @count > 0 case array when Array @result.concat array when Exception @result = array @count = 1 else @result << array end if (@count -= 1) == 0 if Array === @result && Integer === @result.first @feed.call @result.inject(0){|s, i| s + i} else @feed.call @result end end end end |