class Schemacop::V3::Context

Constants

DEFAULT_JSON_FORMAT

Attributes

json_format[RW]
schemas[RW]

Public Class Methods

new(json_format: DEFAULT_JSON_FORMAT) click to toggle source
# File lib/schemacop/v3/context.rb, line 9
def initialize(json_format: DEFAULT_JSON_FORMAT)
  @schemas = {}.with_indifferent_access.freeze
  @json_format = json_format
end

Public Instance Methods

schema(name, type = :hash, **options, &block) click to toggle source
# File lib/schemacop/v3/context.rb, line 14
def schema(name, type = :hash, **options, &block)
  @schemas = @schemas.merge(
    name => Node.create(type, **options, &block)
  ).freeze
end
swagger_json?() click to toggle source
# File lib/schemacop/v3/context.rb, line 28
def swagger_json?
  @json_format == :swagger
end
with_json_format(json_format) { || ... } click to toggle source
# File lib/schemacop/v3/context.rb, line 20
def with_json_format(json_format)
  prev_json_format = @json_format
  @json_format = json_format
  return yield
ensure
  @json_format = prev_json_format
end