Class: JsonPath::Proxy
- Inherits:
-
Object
- Object
- JsonPath::Proxy
- Defined in:
- lib/jsonpath/proxy.rb
Instance Attribute Summary collapse
-
#obj ⇒ Object
(also: #to_hash)
readonly
Returns the value of attribute obj.
Instance Method Summary collapse
- #compact(path = JsonPath::PATH_ALL) ⇒ Object
- #compact!(path = JsonPath::PATH_ALL) ⇒ Object
- #delete(path = JsonPath::PATH_ALL) ⇒ Object
- #delete!(path = JsonPath::PATH_ALL) ⇒ Object
- #gsub(path, replacement = nil, &replacement_block) ⇒ Object
- #gsub!(path, replacement = nil, &replacement_block) ⇒ Object
-
#initialize(obj) ⇒ Proxy
constructor
A new instance of Proxy.
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
#obj ⇒ Object (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 |