Class: JsonPath::Proxy

Inherits:
Object
  • Object
show all
Defined in:
lib/jsonpath/proxy.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(obj) ⇒ Proxy

Returns a new instance of Proxy.



6
7
8
# File 'lib/jsonpath/proxy.rb', line 6

def initialize(obj)
  @obj = obj
end

Instance Attribute Details

#objObject (readonly) Also known as: to_hash

Returns the value of attribute obj.



3
4
5
# File 'lib/jsonpath/proxy.rb', line 3

def obj
  @obj
end

Instance Method Details

#compact(path = JsonPath::PATH_ALL) ⇒ Object



26
27
28
# File 'lib/jsonpath/proxy.rb', line 26

def compact(path = JsonPath::PATH_ALL)
  _compact(_deep_copy, path)
end

#compact!(path = JsonPath::PATH_ALL) ⇒ Object



30
31
32
# File 'lib/jsonpath/proxy.rb', line 30

def compact!(path = JsonPath::PATH_ALL)
  _compact(@obj, path)
end

#delete(path = JsonPath::PATH_ALL) ⇒ Object



18
19
20
# File 'lib/jsonpath/proxy.rb', line 18

def delete(path = JsonPath::PATH_ALL)
  _delete(_deep_copy, path)
end

#delete!(path = JsonPath::PATH_ALL) ⇒ Object



22
23
24
# File 'lib/jsonpath/proxy.rb', line 22

def delete!(path = JsonPath::PATH_ALL)
  _delete(@obj, path)
end

#gsub(path, replacement = nil, &replacement_block) ⇒ Object



10
11
12
# File 'lib/jsonpath/proxy.rb', line 10

def gsub(path, replacement = nil, &replacement_block)
  _gsub(_deep_copy, path, replacement ? proc{replacement} : replacement_block)
end

#gsub!(path, replacement = nil, &replacement_block) ⇒ Object



14
15
16
# File 'lib/jsonpath/proxy.rb', line 14

def gsub!(path, replacement = nil, &replacement_block)
  _gsub(@obj, path, replacement ? proc{replacement} : replacement_block)
end