lib/json_schema/schema.rb in json_schema-0.0.9 vs lib/json_schema/schema.rb in json_schema-0.0.10
- old
+ new
@@ -17,10 +17,14 @@
def initialize
@clones = Set.new
end
+ # Fragment of a JSON Pointer that can help us build a pointer back to this
+ # schema for debugging.
+ attr_accessor :fragment
+
# Rather than a normal schema, the node may be a JSON Reference. In this
# case, no other attributes will be filled in except for #parent.
attr_accessor :reference
attr_copyable :expanded
@@ -251,9 +255,17 @@
end
end
def original?
!clones.include?(self)
+ end
+
+ def pointer
+ if parent
+ parent.pointer + "/" + fragment
+ else
+ fragment
+ end
end
def validate(data)
validator = Validator.new(self)
valid = validator.validate(data)