Class: Tarantool16::Option
- Inherits:
-
Object
- Object
- Tarantool16::Option
- Defined in:
- lib/tarantool16/response.rb
Instance Attribute Summary collapse
-
#error ⇒ Object
readonly
Returns the value of attribute error.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(err, data) ⇒ Option
constructor
A new instance of Option.
- #inspect ⇒ Object
- #ok? ⇒ Boolean
- #raise_if_error! ⇒ Object
Constructor Details
#initialize(err, data) ⇒ Option
4 5 6 7 |
# File 'lib/tarantool16/response.rb', line 4 def initialize(err, data) @error = err @data = data end |
Instance Attribute Details
#error ⇒ Object (readonly)
Returns the value of attribute error.
3 4 5 |
# File 'lib/tarantool16/response.rb', line 3 def error @error end |
Class Method Details
.error(err, message = nil) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/tarantool16/response.rb', line 21 def self.error(err, = nil) if err.is_a? Class err = err.new end new(err, nil) end |
.ok(data) ⇒ Object
17 18 19 |
# File 'lib/tarantool16/response.rb', line 17 def self.ok(data) new(nil, data) end |
Instance Method Details
#inspect ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/tarantool16/response.rb', line 28 def inspect if ok? "<Option data=#{@data.inspect}>" else "<Option error=#{@error.inspect}>" end end |
#ok? ⇒ Boolean
9 10 11 |
# File 'lib/tarantool16/response.rb', line 9 def ok? !@error end |
#raise_if_error! ⇒ Object
13 14 15 |
# File 'lib/tarantool16/response.rb', line 13 def raise_if_error! raise @error if @error end |