class ApiResource::Mocks::MockResponse

Attributes

block[R]
body[R]
code[R]
format[R]
headers[R]

Public Class Methods

new(body, opts = {}, &block) click to toggle source
# File lib/api_resource/mocks.rb, line 132
def initialize(body, opts = {}, &block)     
  opts = opts.reverse_merge({:headers => {}, :status_code => 200})
  @body = body
  @headers = opts[:headers]
  @code = opts[:status_code]
  @format = (opts[:format] || :json)
  @block = block if block_given?
end

Public Instance Methods

[](key) click to toggle source
# File lib/api_resource/mocks.rb, line 143
def [](key)
  @headers[key]
end
[]=(key, val) click to toggle source
# File lib/api_resource/mocks.rb, line 140
def []=(key, val)
  @headers[key] = val
end
body_as_object() click to toggle source
# File lib/api_resource/mocks.rb, line 152
def body_as_object
  return @body
end
generate_response(params) click to toggle source
# File lib/api_resource/mocks.rb, line 156
def generate_response(params)
  @body = @body.instance_exec(params, &self.block) if self.block
end