Class: TrueConf::Response

Inherits:
Object
  • Object
show all
Extended by:
Dry::Initializer
Defined in:
lib/true-conf/response.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.build(*res) ⇒ Object



16
17
18
19
20
# File 'lib/true-conf/response.rb', line 16

def build(*res)
  body = res.last
  attr = name.split("::").last.downcase
  new JSON.parse(body.first)[attr]
end

.new(opts) ⇒ Object



22
23
24
# File 'lib/true-conf/response.rb', line 22

def new(opts)
  super opts.each_with_object({}) { |(key, val), obj| obj[key.to_sym] = val }
end

Instance Method Details

#error?Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/true-conf/response.rb', line 7

def error?
  is_a?(TrueConf::Error)
end

#success?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/true-conf/response.rb', line 11

def success?
  !error?
end