Class: EM::Mongo::ServerResponse
- Inherits:
-
Object
- Object
- EM::Mongo::ServerResponse
- Defined in:
- lib/em-mongo/server_response.rb
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
-
#cursor_id ⇒ Object
readonly
Returns the value of attribute cursor_id.
-
#docs ⇒ Object
readonly
Returns the value of attribute docs.
-
#number_returned ⇒ Object
readonly
Returns the value of attribute number_returned.
-
#op ⇒ Object
readonly
Returns the value of attribute op.
-
#request_id ⇒ Object
readonly
Returns the value of attribute request_id.
-
#response_to ⇒ Object
readonly
Returns the value of attribute response_to.
-
#result_flags ⇒ Object
readonly
Returns the value of attribute result_flags.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
-
#starting_from ⇒ Object
readonly
Returns the value of attribute starting_from.
Instance Method Summary collapse
-
#initialize(buffer, connection) ⇒ ServerResponse
constructor
A new instance of ServerResponse.
Constructor Details
#initialize(buffer, connection) ⇒ ServerResponse
Returns a new instance of ServerResponse.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/em-mongo/server_response.rb', line 9 def initialize(buffer, connection) @connection = connection # Header @size = buffer.get_int @request_id = buffer.get_int @response_to = buffer.get_int @op = buffer.get_int # Response Header @result_flags = buffer.get_int @cursor_id = buffer.get_long @starting_from = buffer.get_int @number_returned = buffer.get_int # Documents pos = buffer.position @docs = (1..@number_returned).map do size= @connection.peek_size(buffer) doc = BSON::BSON_CODER.deserialize(buffer.to_s[pos,size]) pos += size buffer.position = pos doc end end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
4 5 6 |
# File 'lib/em-mongo/server_response.rb', line 4 def connection @connection end |
#cursor_id ⇒ Object (readonly)
Returns the value of attribute cursor_id.
4 5 6 |
# File 'lib/em-mongo/server_response.rb', line 4 def cursor_id @cursor_id end |
#docs ⇒ Object (readonly)
Returns the value of attribute docs.
4 5 6 |
# File 'lib/em-mongo/server_response.rb', line 4 def docs @docs end |
#number_returned ⇒ Object (readonly)
Returns the value of attribute number_returned.
4 5 6 |
# File 'lib/em-mongo/server_response.rb', line 4 def number_returned @number_returned end |
#op ⇒ Object (readonly)
Returns the value of attribute op.
4 5 6 |
# File 'lib/em-mongo/server_response.rb', line 4 def op @op end |
#request_id ⇒ Object (readonly)
Returns the value of attribute request_id.
4 5 6 |
# File 'lib/em-mongo/server_response.rb', line 4 def request_id @request_id end |
#response_to ⇒ Object (readonly)
Returns the value of attribute response_to.
4 5 6 |
# File 'lib/em-mongo/server_response.rb', line 4 def response_to @response_to end |
#result_flags ⇒ Object (readonly)
Returns the value of attribute result_flags.
4 5 6 |
# File 'lib/em-mongo/server_response.rb', line 4 def result_flags @result_flags end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
4 5 6 |
# File 'lib/em-mongo/server_response.rb', line 4 def size @size end |
#starting_from ⇒ Object (readonly)
Returns the value of attribute starting_from.
4 5 6 |
# File 'lib/em-mongo/server_response.rb', line 4 def starting_from @starting_from end |