Class: JSONRef
- Inherits:
-
Object
- Object
- JSONRef
- Defined in:
- lib/json-ref.rb
Constant Summary collapse
- VERSION =
'0.1.0'
Class Method Summary collapse
Instance Method Summary collapse
- #expand ⇒ Object
-
#initialize(document) ⇒ JSONRef
constructor
A new instance of JSONRef.
Constructor Details
#initialize(document) ⇒ JSONRef
Returns a new instance of JSONRef.
5 6 7 |
# File 'lib/json-ref.rb', line 5 def initialize(document) @document = document end |
Class Method Details
.expand(document) ⇒ Object
17 18 19 |
# File 'lib/json-ref.rb', line 17 def self.(document) self.new(document). end |
Instance Method Details
#expand ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/json-ref.rb', line 9 def @document.each do |k,v| if v.is_a?(Hash) && v.has_key?('$ref') @document[k] = split_path(v['$ref']).inject(@document) { |doc, item| doc[item] } end end end |