Sha256: 21e9498c522e43aabe2a21283e452c3de29af165e81397be58116a7148e6f6eb

Contents?: true

Size: 888 Bytes

Versions: 11

Compression:

Stored size: 888 Bytes

Contents

require 'tomograph/path'

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

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

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
tomograph-2.5.4 lib/tomograph/tomogram/action.rb
tomograph-2.5.3 lib/tomograph/tomogram/action.rb
tomograph-2.5.2 lib/tomograph/tomogram/action.rb
tomograph-2.5.1 lib/tomograph/tomogram/action.rb
tomograph-2.5.0 lib/tomograph/tomogram/action.rb
tomograph-2.4.2 lib/tomograph/tomogram/action.rb
tomograph-2.4.1 lib/tomograph/tomogram/action.rb
tomograph-2.4.0 lib/tomograph/tomogram/action.rb
tomograph-2.3.0 lib/tomograph/tomogram/action.rb
tomograph-2.2.1 lib/tomograph/tomogram/action.rb
tomograph-2.2.0 lib/tomograph/tomogram/action.rb