Sha256: db3107d693c688cb70d5915c8a1dcf3b153069113d1abf8f24ff0f39fbf04643

Contents?: true

Size: 1.12 KB

Versions: 2

Compression:

Stored size: 1.12 KB

Contents

# -*- encoding : utf-8 -*-
module Pacto
  module Formats
    module Legacy
      class RequestClause < Pacto::Dash
        include Pacto::RequestClause
        extend Forwardable
        attr_reader :data
        def_delegators :data, :to_hash
        def_delegators :data, :host, :http_method, :schema, :path, :headers, :params
        def_delegators :data, :host=, :http_method=, :schema=, :path=, :headers=, :params=

        class Data < Pacto::Dash
          property :host # required?
          property :http_method, required: true
          property :schema, default: {}
          property :path, default: '/'
          property :headers, default: {}
          property :params, default: {}
        end

        def initialize(data)
          skip_freeze = data.delete(:skip_freeze)
          mash = Hashie::Mash.new data
          mash['http_method'] = normalize(mash['http_method'])
          @data = Data.new(mash)
          freeze unless skip_freeze
          super({})
          @pattern = Pacto::RequestPattern.for(self)
        end

        def freeze
          @data.freeze
          self
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pacto-0.4.0.rc3 lib/pacto/formats/legacy/request_clause.rb
pacto-0.4.0.rc2 lib/pacto/formats/legacy/request_clause.rb