Sha256: 06ca194f0949f159bda03f0c634a3274b1b25f81c69cbbe44862cd05b6a8c8a8

Contents?: true

Size: 894 Bytes

Versions: 15

Compression:

Stored size: 894 Bytes

Contents

require 'tomograph/path'

module Tomograph
  class Tomogram
    class Action
      attr_reader :path, :method, :content_type, :requests, :responses, :resource

      def initialize(path:, method:, content_type:, requests:, responses:, resource:)
        @path ||= Tomograph::Path.new(path)
        @method ||= method
        @content_type ||= content_type
        @requests ||= requests
        @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,
          'content-type' => content_type,
          'requests' => requests,
          'responses' => responses,
          'resource' => resource
        }
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
tomograph-3.2.7 lib/tomograph/tomogram/action.rb
tomograph-3.2.6 lib/tomograph/tomogram/action.rb
tomograph-3.2.5 lib/tomograph/tomogram/action.rb
tomograph-3.2.4 lib/tomograph/tomogram/action.rb
tomograph-3.2.1 lib/tomograph/tomogram/action.rb
tomograph-3.2.0 lib/tomograph/tomogram/action.rb
tomograph-3.1.6 lib/tomograph/tomogram/action.rb
tomograph-3.1.5 lib/tomograph/tomogram/action.rb
tomograph-3.1.4 lib/tomograph/tomogram/action.rb
tomograph-3.1.3 lib/tomograph/tomogram/action.rb
tomograph-3.1.2 lib/tomograph/tomogram/action.rb
tomograph-3.1.1 lib/tomograph/tomogram/action.rb
tomograph-3.1.0 lib/tomograph/tomogram/action.rb
tomograph-3.0.1 lib/tomograph/tomogram/action.rb
tomograph-3.0.0 lib/tomograph/tomogram/action.rb