class Shokkenki::Consumer::Stubber::Interaction

Attributes

label[R]
matched_requests[R]
request[R]
response[R]
time[R]

Public Class Methods

from_json(json) click to toggle source
# File lib/shokkenki/consumer/stubber/interaction.rb, line 11
def self.from_json json
  attributes = json.with_indifferent_access

  new(
    :label => attributes[:label],
    :request => Shokkenki::Term::TermFactory.from_json(attributes[:request]),
    :response => Shokkenki::Term::TermFactory.from_json(attributes[:response]),
    :time => attributes[:time]
  )
end
new(attributes) click to toggle source
# File lib/shokkenki/consumer/stubber/interaction.rb, line 22
def initialize attributes
  @label = attributes[:label]
  @request = attributes[:request]
  @response = attributes[:response]
  @time = attributes[:time]
  @matched_requests = []
end

Public Instance Methods

add_match(request) click to toggle source
# File lib/shokkenki/consumer/stubber/interaction.rb, line 44
def add_match request
  @matched_requests << request
  request.interaction = self
end
generate_response() click to toggle source
# File lib/shokkenki/consumer/stubber/interaction.rb, line 36
def generate_response
  @response.example
end
match_request?(request) click to toggle source
# File lib/shokkenki/consumer/stubber/interaction.rb, line 40
def match_request? request
  @request.match? request
end
to_hash() click to toggle source
# File lib/shokkenki/consumer/stubber/interaction.rb, line 30
def to_hash
  {
    :label => @label
  }
end