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.



8
9
10
# File 'lib/jsonpath/proxy.rb', line 8

def initialize(obj)
  @obj = obj
end

Instance Attribute Details

#objObject (readonly) Also known as: to_hash

Returns the value of attribute obj.



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

def obj
  @obj
end

Instance Method Details

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



28
29
30
# File 'lib/jsonpath/proxy.rb', line 28

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

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



32
33
34
# File 'lib/jsonpath/proxy.rb', line 32

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

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



20
21
22
# File 'lib/jsonpath/proxy.rb', line 20

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

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



24
25
26
# File 'lib/jsonpath/proxy.rb', line 24

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

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



12
13
14
# File 'lib/jsonpath/proxy.rb', line 12

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

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



16
17
18
# File 'lib/jsonpath/proxy.rb', line 16

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