Class: Tarantool16::Connection::Option
- Inherits:
-
Object
- Object
- Tarantool16::Connection::Option
- Defined in:
- lib/tarantool16/connection/response.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#sync ⇒ Object
readonly
Returns the value of attribute sync.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(sync, err, data) ⇒ Option
constructor
A new instance of Option.
- #inspect ⇒ Object
- #ok? ⇒ Boolean
- #raise_if_error! ⇒ Object
Constructor Details
#initialize(sync, err, data) ⇒ Option
Returns a new instance of Option.
8 9 10 11 12 |
# File 'lib/tarantool16/connection/response.rb', line 8 def initialize(sync, err, data) @sync = sync @error = err @data = data end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
7 8 9 |
# File 'lib/tarantool16/connection/response.rb', line 7 def data @data end |
#error ⇒ Object (readonly)
Returns the value of attribute error.
7 8 9 |
# File 'lib/tarantool16/connection/response.rb', line 7 def error @error end |
#sync ⇒ Object (readonly)
Returns the value of attribute sync.
7 8 9 |
# File 'lib/tarantool16/connection/response.rb', line 7 def sync @sync end |
Class Method Details
.error(sync, err, message = nil) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/tarantool16/connection/response.rb', line 30 def self.error(sync, err, = nil) if err.is_a? Class err = err.new end new(sync, err, nil) end |
.ok(sync, code, data) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/tarantool16/connection/response.rb', line 22 def self.ok(sync, code, data) if code == 0 new(sync, nil, data) else new(sync, ::Tarantool16::DBError.(code&(REQUEST_TYPE_ERROR-1), data), nil) end end |
Instance Method Details
#inspect ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/tarantool16/connection/response.rb', line 37 def inspect s = @sync ? " sync=#{sync}" : "" if ok? "<Option#{s} data=#{@data.inspect}>" else "<Option#{s} error=#{@error.inspect}>" end end |
#ok? ⇒ Boolean
14 15 16 |
# File 'lib/tarantool16/connection/response.rb', line 14 def ok? !@error end |
#raise_if_error! ⇒ Object
18 19 20 |
# File 'lib/tarantool16/connection/response.rb', line 18 def raise_if_error! raise @error if @error end |