Sha256: e388400bd0a6d1d907d2e122e921c44f626e9e382b53c579749cba26eae41aa3
Contents?: true
Size: 1.16 KB
Versions: 2
Compression:
Stored size: 1.16 KB
Contents
# frozen_string_literal: true module MediaTypes class Scheme class ValidationOptions attr_accessor :exhaustive, :strict, :backtrace, :context def initialize(context = {}, exhaustive: true, strict: true, backtrace: []) self.exhaustive = exhaustive self.strict = strict self.backtrace = backtrace self.context = context end def inspect "backtrack: #{backtrace.inspect}, strict: #{strict.inspect}, exhaustive: #{exhaustive}, current_obj: #{scoped_output.to_json}" end def scoped_output current = context backtrace.drop(1).first([0, backtrace.size - 2].max).each do |e| current = current[e] unless current.nil? end current end def with_backtrace(backtrace) ValidationOptions.new(context, exhaustive: exhaustive, strict: strict, backtrace: backtrace) end def trace(*traces) with_backtrace(backtrace.dup.concat(traces)) end def exhaustive! ValidationOptions.new(context, exhaustive: true, strict: strict, backtrace: backtrace) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
media_types-2.0.1 | lib/media_types/scheme/validation_options.rb |
media_types-2.0.0 | lib/media_types/scheme/validation_options.rb |