Sha256: 95d9ffc41ec50279859c24c7c5c23b93823af660d879283b3e2a795c5f172acb

Contents?: true

Size: 1.49 KB

Versions: 3

Compression:

Stored size: 1.49 KB

Contents

# frozen_string_literal: true

require 'forwardable'
require 'key_flatten'

require 'r2-oas/plugin/executor'
require 'r2-oas/schema/v3/object/store'

module R2OAS
  module Schema
    module V3
      module FromFiles
        class BaseObject
          extend Forwardable

          class << self
            def obj_store
              ::R2OAS::Schema::V3::Store.create(:obj)
            end
          end

          def_delegators :@plugin_executor, :execute_transform_plugins

          def initialize(opts = {})
            @opts = opts
            plugins = app_configuration_options[:plugins]
            @plugin_executor = ::R2OAS::Plugin::Executor.new(plugins, opts)
          end

          def to_doc
            raise 'Implement Inherit Class'
          end

          private

          def obj_store
            self.class.obj_store
          end

          def set_root_doc(root_doc)
            obj_store.root_doc = root_doc.dup
          end

          def root_doc
            obj_store.root_doc
          end

          def set_components_name_list(root_doc)
            obj_store.components_schema_name_list = (root_doc.fetch('components', nil)&.fetch('schemas', nil) || {}).keys.sort.uniq
            obj_store.components_request_body_name_list = (root_doc.fetch('components', nil)&.fetch('schemas', nil) || {}).keys.sort.uniq
          end

          def app_configuration_options
            R2OAS.app_configuration_options
          end

          attr_accessor :opts
        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/schema/v3/object/from_files/base_object.rb
r2-oas-0.4.1 lib/r2-oas/schema/v3/object/from_files/base_object.rb
r2-oas-0.4.0 lib/r2-oas/schema/v3/object/from_files/base_object.rb