Sha256: 0535a16e45355342c08a943524f60875ace27919a0461aa9671e3e5c6e4040ba

Contents?: true

Size: 732 Bytes

Versions: 4

Compression:

Stored size: 732 Bytes

Contents

require 'tomograph/path'

module Tomograph
  class Tomogram
    class Action
      attr_reader :path, :method, :request, :responses

      def initialize(path:, method:, request:, responses:, resource:)
        @path ||= Tomograph::Path.new(path)
        @method ||= method
        @request ||= request
        @responses ||= responses
        @resource ||= resource
      end

      def find_responses(status:)
        to_hash['responses'].find_all do |response|
          response['status'] == status.to_s
        end
      end

      def to_hash
        @action ||= {
          'path' => path,
          'method' => method,
          'request' => request,
          'responses' => responses
        }
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
tomograph-2.0.1 lib/tomograph/tomogram/action.rb
tomograph-2.0.0 lib/tomograph/tomogram/action.rb
tomograph-1.2.0 lib/tomograph/tomogram/action.rb
tomograph-1.1.0 lib/tomograph/tomogram/action.rb