Sha256: 3a59f0d97184f1623b1ef81241e983256cc483b5e640beaa9e24eaa94a722084

Contents?: true

Size: 761 Bytes

Versions: 25

Compression:

Stored size: 761 Bytes

Contents

module Schemacop
  module V3
    class Context
      attr_accessor :schemas
      attr_accessor :json_format

      DEFAULT_JSON_FORMAT = :default

      def initialize(json_format: DEFAULT_JSON_FORMAT)
        @schemas = {}.with_indifferent_access.freeze
        @json_format = json_format
      end

      def schema(name, type = :hash, **options, &block)
        @schemas = @schemas.merge(
          name => Node.create(type, **options, &block)
        ).freeze
      end

      def with_json_format(json_format)
        prev_json_format = @json_format
        @json_format = json_format
        return yield
      ensure
        @json_format = prev_json_format
      end

      def swagger_json?
        @json_format == :swagger
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
schemacop-3.0.30 lib/schemacop/v3/context.rb
schemacop-3.0.29 lib/schemacop/v3/context.rb
schemacop-3.0.28 lib/schemacop/v3/context.rb
schemacop-3.0.27 lib/schemacop/v3/context.rb
schemacop-3.0.26 lib/schemacop/v3/context.rb
schemacop-3.0.25 lib/schemacop/v3/context.rb
schemacop-3.0.24 lib/schemacop/v3/context.rb
schemacop-3.0.23 lib/schemacop/v3/context.rb
schemacop-3.0.22 lib/schemacop/v3/context.rb
schemacop-3.0.21 lib/schemacop/v3/context.rb
schemacop-3.0.20 lib/schemacop/v3/context.rb
schemacop-3.0.19 lib/schemacop/v3/context.rb
schemacop-3.0.18 lib/schemacop/v3/context.rb
schemacop-3.0.17 lib/schemacop/v3/context.rb
schemacop-3.0.16 lib/schemacop/v3/context.rb
schemacop-3.0.15 lib/schemacop/v3/context.rb
schemacop-3.0.14 lib/schemacop/v3/context.rb
schemacop-3.0.13 lib/schemacop/v3/context.rb
schemacop-3.0.12 lib/schemacop/v3/context.rb
schemacop-3.0.11 lib/schemacop/v3/context.rb