Class: Patchboard::Response

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw) ⇒ Response

Returns a new instance of Response.



6
7
8
9
10
11
12
13
# File 'lib/patchboard/response.rb', line 6

def initialize(raw)
  @raw = raw
  if @raw.headers["Content-Type"]
    if @raw.headers["Content-Type"] =~ %r{application/.*json}
      @data = JSON.parse @raw.body, :symbolize_names => true
    end
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



15
16
17
18
19
20
21
# File 'lib/patchboard/response.rb', line 15

def method_missing(name, *args, &block)
  if @raw.respond_to? name
    @raw.send(name, *args, &block)
  else
    super
  end
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



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

def data
  @data
end

#rawObject (readonly)

Returns the value of attribute raw.



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

def raw
  @raw
end

#resourceObject

Returns the value of attribute resource.



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

def resource
  @resource
end

Instance Method Details

#respond_to?(*args) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/patchboard/response.rb', line 23

def respond_to?(*args)
  @raw.respond_to?(*args) || super
end