Class: WCC::Data::Response

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw) ⇒ Response

Returns a new instance of Response.



7
8
9
# File 'lib/wcc/data/response.rb', line 7

def initialize(raw)
  @raw = raw
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/wcc/data/response.rb', line 16

def method_missing(method, *args, &block)
  if raw.respond_to?(method)
    raw.public_send(method, *args, &block)
  else
    super
  end
end

Instance Attribute Details

#rawObject (readonly)

Returns the value of attribute raw.



5
6
7
# File 'lib/wcc/data/response.rb', line 5

def raw
  @raw
end

Instance Method Details

#jsonObject



11
12
13
14
# File 'lib/wcc/data/response.rb', line 11

def json
  JSON.parse(body)
rescue JSON::ParserError
end

#respond_to?(method) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/wcc/data/response.rb', line 24

def respond_to?(method)
  super || raw.respond_to?(method)
end