Sha256: 97d08fede7f421350e387924d9bcaed4d55390769a888a072e27538855435fb0

Contents?: true

Size: 846 Bytes

Versions: 2

Compression:

Stored size: 846 Bytes

Contents

# frozen_string_literal: true

module MediaTypes
  class Scheme
    class ValidationOptions
      attr_accessor :exhaustive, :strict, :backtrace

      def initialize(exhaustive: true, strict: true, backtrace: [])
        self.exhaustive = exhaustive
        self.strict = strict
        self.backtrace = backtrace
      end

      def inspect
        "backtrack: #{backtrace.inspect}, strict: #{strict.inspect}, exhaustive: #{exhaustive}"
      end

      def with_backtrace(backtrace)
        ValidationOptions.new(exhaustive: exhaustive, strict: strict, backtrace: backtrace)
      end

      def trace(*traces)
        with_backtrace(backtrace.dup.concat(traces))
      end

      def exhaustive!
        ValidationOptions.new(exhaustive: true, strict: strict, backtrace: backtrace)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
media_types-1.0.0 lib/media_types/scheme/validation_options.rb
media_types-0.6.2 lib/media_types/scheme/validation_options.rb