Class: JsonPath::Nodes::Object

Inherits:
Base
  • Object
show all
Defined in:
lib/json_path/nodes/object.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#children, #path

Instance Method Summary collapse

Methods inherited from Base

#query

Constructor Details

#initialize(path, hash) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/json_path/nodes/object.rb', line 6

def initialize path, hash
  super path
  @hash = hash.to_h do |key, value|
    [key, Nodes.parse("#{path}['#{key}']", value)]
  end
  @children = self.hash.values
end

Instance Attribute Details

#hashObject (readonly)

Returns the value of attribute hash.



4
5
6
# File 'lib/json_path/nodes/object.rb', line 4

def hash
  @hash
end

Instance Method Details

#valueObject



14
15
16
# File 'lib/json_path/nodes/object.rb', line 14

def value
  hash.transform_values(&:value)
end