Class: ValidationFailure

Inherits:
Object
  • Object
show all
Includes:
DeepEquality, HashInitialized, Inspectable
Defined in:
lib/json_patterns.rb

Direct Known Subclasses

ValidationAmbiguity, ValidationUnexpected

Constant Summary

Constants included from Inspectable

Inspectable::INSPECTING_KEY

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from HashInitialized

#initialize

Methods included from DeepEquality

#==

Methods included from Inspectable

#inspect

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



213
214
215
# File 'lib/json_patterns.rb', line 213

def path
  @path
end

Instance Method Details

#path_to_sObject



222
223
224
# File 'lib/json_patterns.rb', line 222

def path_to_s
  '$' + @path.map { |p| "[#{ p.is_a?(String) ? "'#{p.to_s}'" : p.to_s }]" }.join('')
end

#to_jsonObject



215
216
217
218
219
220
# File 'lib/json_patterns.rb', line 215

def to_json
  Hash[*self.instance_variables.map { |var|
    val = self.instance_variable_get(var)
    [var.to_s.sub('@', ''), (val.is_a?(Set) ? val.to_a : val)]
  }.reduce(:+)]
end