Sha256: 72f519b7eb85b8f6fc28a2320cfd06ffb77c42df91e50f8ddf5d021bc91aa8ea

Contents?: true

Size: 689 Bytes

Versions: 4

Compression:

Stored size: 689 Bytes

Contents

# frozen_string_literal: true

class Zilla::Versions::V20::Path
  include Zilla::Versions::V20

  include Memery

  VERBS = ["get", "post", "put", "patch", "delete", "head", "options"].freeze

  attr_reader :path, :json, :definitions

  def initialize(path, json, definitions: {})
    @path = path
    @json = json
    @definitions = definitions
  end

  memoize def endpoints
    parameters = json.fetch("parameters", []) # weird kubernetes API definition

    json.each_with_object({}) do |(k, v), acc|
      next unless VERBS.include?(k)

      v = v.merge("parameters" => v.fetch("parameters", []) + parameters)

      acc[k] = Endpoint.new(path, k, v, definitions:)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
zilla-0.1.5 lib/zilla/versions/v20/path.rb
zilla-0.1.4 lib/zilla/versions/v20/path.rb
zilla-0.1.3 lib/zilla/versions/v20/path.rb
zilla-0.1.2 lib/zilla/versions/v20/path.rb