Class: Tarantool16::Option

Inherits:
Object
  • Object
show all
Defined in:
lib/tarantool16/response.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(err, data) ⇒ Option

Returns a new instance of Option.



4
5
6
7
# File 'lib/tarantool16/response.rb', line 4

def initialize(err, data)
  @error = err
  @data = data
end

Instance Attribute Details

#errorObject (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, message = nil)
  if err.is_a? Class
    err = err.new message
  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

#inspectObject



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

Returns:

  • (Boolean)


9
10
11
# File 'lib/tarantool16/response.rb', line 9

def ok?
  !@error
end

#raise_if_error!Object

Raises:



13
14
15
# File 'lib/tarantool16/response.rb', line 13

def raise_if_error!
  raise @error if @error
end