Class: MediaTypes::Scheme::ValidationOptions
- Inherits:
-
Object
- Object
- MediaTypes::Scheme::ValidationOptions
- Defined in:
- lib/media_types/scheme/validation_options.rb
Instance Attribute Summary collapse
-
#backtrace ⇒ Object
Returns the value of attribute backtrace.
-
#context ⇒ Object
Returns the value of attribute context.
-
#exhaustive ⇒ Object
Returns the value of attribute exhaustive.
-
#strict ⇒ Object
Returns the value of attribute strict.
Instance Method Summary collapse
- #exhaustive! ⇒ Object
-
#initialize(context = {}, exhaustive: true, strict: true, backtrace: []) ⇒ ValidationOptions
constructor
A new instance of ValidationOptions.
- #inspect ⇒ Object
- #scoped_output ⇒ Object
- #trace(*traces) ⇒ Object
- #with_backtrace(backtrace) ⇒ Object
Constructor Details
#initialize(context = {}, exhaustive: true, strict: true, backtrace: []) ⇒ ValidationOptions
Returns a new instance of ValidationOptions.
8 9 10 11 12 13 |
# File 'lib/media_types/scheme/validation_options.rb', line 8 def initialize(context = {}, exhaustive: true, strict: true, backtrace: []) self.exhaustive = exhaustive self.strict = strict self.backtrace = backtrace self.context = context end |
Instance Attribute Details
#backtrace ⇒ Object
Returns the value of attribute backtrace.
6 7 8 |
# File 'lib/media_types/scheme/validation_options.rb', line 6 def backtrace @backtrace end |
#context ⇒ Object
Returns the value of attribute context.
6 7 8 |
# File 'lib/media_types/scheme/validation_options.rb', line 6 def context @context end |
#exhaustive ⇒ Object
Returns the value of attribute exhaustive.
6 7 8 |
# File 'lib/media_types/scheme/validation_options.rb', line 6 def exhaustive @exhaustive end |
#strict ⇒ Object
Returns the value of attribute strict.
6 7 8 |
# File 'lib/media_types/scheme/validation_options.rb', line 6 def strict @strict end |
Instance Method Details
#exhaustive! ⇒ Object
37 38 39 |
# File 'lib/media_types/scheme/validation_options.rb', line 37 def exhaustive! ValidationOptions.new(context, exhaustive: true, strict: strict, backtrace: backtrace) end |
#inspect ⇒ Object
15 16 17 |
# File 'lib/media_types/scheme/validation_options.rb', line 15 def inspect "backtrack: #{backtrace.inspect}, strict: #{strict.inspect}, exhaustive: #{exhaustive}, current_obj: #{scoped_output.to_json}" end |
#scoped_output ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/media_types/scheme/validation_options.rb', line 19 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 |
#trace(*traces) ⇒ Object
33 34 35 |
# File 'lib/media_types/scheme/validation_options.rb', line 33 def trace(*traces) with_backtrace(backtrace.dup.concat(traces)) end |
#with_backtrace(backtrace) ⇒ Object
29 30 31 |
# File 'lib/media_types/scheme/validation_options.rb', line 29 def with_backtrace(backtrace) ValidationOptions.new(context, exhaustive: exhaustive, strict: strict, backtrace: backtrace) end |