Sha256: 0b2a4b841bde1e62774d92d47f75b08c5e649305775dd5bcac463a55cba4c413

Contents?: true

Size: 869 Bytes

Versions: 3

Compression:

Stored size: 869 Bytes

Contents

# frozen_string_literal: true

require 'r2-oas/plugin/hookable'

module R2OAS
  module Plugin
    module V3
      module Visitable
        include R2OAS::Plugin::Hookable

        SCHEMA_OBJECTS = %i[
          info
          path_item
          external_document
          components_schema
          components_request_body
          components_schema_name
          components_schema_name_at_request_body
          components_request_body_name
        ].freeze

        SCHEMA_OBJECTS.each do |schema_name|
          define_method schema_name.to_s do |&block|
            return if block.blank?

            callback = proc { |*args| block.call(*args) }
            on(schema_name, callback)
          end

          define_method "execute_#{schema_name}" do |*args|
            execute_hook(schema_name, *args)
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
r2-oas-0.5.0 lib/r2-oas/plugin/transform/v3/visitable.rb
r2-oas-0.4.1 lib/r2-oas/plugin/transform/v3/visitable.rb
r2-oas-0.4.0 lib/r2-oas/plugin/transform/v3/visitable.rb