Sha256: ae658d8b4fb2218ab300638dec258b0bdc0d912f777a71b5fb22aef18d8c593a

Contents?: true

Size: 1.2 KB

Versions: 8

Compression:

Stored size: 1.2 KB

Contents

require 'json'
require 'fitting/records/spherical/response'

module Fitting
  class Records
    class Spherical
      class Request
        attr_reader :method, :path, :body, :response, :title, :group, :host

        def initialize(method:, path:, body:, response:, title:, group:, host:)
          @method = method
          @path = path
          @body = body
          @response = response
          @title = title
          @group = group
          @host = host
        end

        def to_hash
          {
            method: method,
            path: path.to_s,
            body: body,
            response: response.to_hash,
            title: title,
            group: group,
            host: host
          }
        end

        def to_json(*_args)
          JSON.dump(to_hash)
        end

        class << self
          def load(hash)
            new(
              method: hash['method'],
              path: hash['path'],
              body: hash['body'],
              response: Fitting::Records::Spherical::Response.load(hash['response']),
              title: hash['title'],
              group: hash['group'],
              host: hash['host']
            )
          end
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
fitting-4.2.1 lib/fitting/records/spherical/request.rb
fitting-4.2.0 lib/fitting/records/spherical/request.rb
fitting-4.1.0 lib/fitting/records/spherical/request.rb
fitting-4.0.4 lib/fitting/records/spherical/request.rb
fitting-4.0.3 lib/fitting/records/spherical/request.rb
fitting-4.0.2 lib/fitting/records/spherical/request.rb
fitting-4.0.1 lib/fitting/records/spherical/request.rb
fitting-4.0.0 lib/fitting/records/spherical/request.rb