Class: Couchbase::View::AsyncHelper
- Inherits:
-
Object
- Object
- Couchbase::View::AsyncHelper
- Includes:
- Constants
- Defined in:
- lib/couchbase/view.rb
Overview
:nodoc:
Constant Summary collapse
- EMPTY =
[]
Constants included from Constants
Constants::S_CAS, Constants::S_DOC, Constants::S_FLAGS, Constants::S_ID, Constants::S_IS_LAST, Constants::S_KEY, Constants::S_META, Constants::S_VALUE
Instance Method Summary collapse
- #complete! ⇒ Object
-
#initialize(wrapper_class, bucket, include_docs, quiet, block) ⇒ AsyncHelper
constructor
A new instance of AsyncHelper.
-
#push(obj) ⇒ Object
Register object in the emitter.
Constructor Details
#initialize(wrapper_class, bucket, include_docs, quiet, block) ⇒ AsyncHelper
Returns a new instance of AsyncHelper.
78 79 80 81 82 83 84 85 86 87 |
# File 'lib/couchbase/view.rb', line 78 def initialize(wrapper_class, bucket, include_docs, quiet, block) @wrapper_class = wrapper_class @bucket = bucket @block = block @quiet = quiet @include_docs = include_docs @queue = [] @first = @shift = 0 @completed = false end |
Instance Method Details
#complete! ⇒ Object
111 112 113 114 115 116 117 118 119 120 |
# File 'lib/couchbase/view.rb', line 111 def complete! if @include_docs @completed = true check_for_ready_documents elsif !@queue.empty? obj = @queue.shift obj[S_IS_LAST] = true block_call obj end end |
#push(obj) ⇒ Object
Register object in the emitter.
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/couchbase/view.rb', line 90 def push(obj) if @include_docs @queue << obj @bucket.get(obj[S_ID], :extended => true, :quiet => @quiet) do |res| obj[S_DOC] = { S_VALUE => res.value, S_META => { S_ID => obj[S_ID], S_FLAGS => res.flags, S_CAS => res.cas } } check_for_ready_documents end else old_obj = @queue.shift @queue << obj block_call(old_obj) if old_obj end end |