Sha256: 1033b88e27575e1e624eabfa1e6a77850b445417c007b9678321d1f19896bb17

Contents?: true

Size: 661 Bytes

Versions: 1

Compression:

Stored size: 661 Bytes

Contents

require "mountapi/open_api/operation"

module Mountapi
  module OpenApi
    class Path
      attr_reader :path, :spec, :version

      def initialize(path, spec, version)
        @path = path
        @spec = spec
        @version = version
      end

      def operations
        operation_nodes.inject([]) do |ops, op|
          ops.push(Operation.new(*op, path, version))
        end
      end

      def to_routes
        operations.map(&:to_route)
      end

      private

      def operation_nodes
        spec.node_data.select do |name, _value|
          Operation::METHODS.include?(name) && !spec.send(name).nil?
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mountapi-0.11.1 lib/mountapi/open_api/path.rb