class Contracto::Contract

Attributes

responses[R]

Public Class Methods

new(hash) click to toggle source
# File lib/contracto/contract.rb, line 8
def initialize(hash)
  @hash = hash
  @request   = Contracto::Contract::Request.new(@hash.fetch('schema').fetch('request'))
  @responses = Contracto::Contract::Responses.new(@hash.fetch('examples'))
end

Public Instance Methods

http_method() click to toggle source
# File lib/contracto/contract.rb, line 14
def http_method
  @request.http_method
end
response_body(params, headers) click to toggle source
# File lib/contracto/contract.rb, line 22
def response_body(params, headers)
  response = @responses.find_by_params_and_headers(params, headers)
  raise Contracto::ResponseNotFoundError.new(params) unless response
  response.body.tap do
    Contracto::Stats.used_contracts << self unless Contracto::Stats.used_contracts.include?(self)
  end
end
url_pattern() click to toggle source
# File lib/contracto/contract.rb, line 18
def url_pattern
  @request.url_pattern
end