lib/dense/methods.rb in dense-1.1.1 vs lib/dense/methods.rb in dense-1.1.2
- old
+ new
@@ -1,19 +1,19 @@
module Dense; class << self
def get(o, path)
- pa = Dense::Path.new(path)
+ pa = Dense::Path.make(path)
r = pa.gather(o).inject([]) { |a, e| a << e[2][e[3]] if e.first; a }
pa.narrow(r)
end
def fetch(o, path, default=::KeyError, &block)
- pa = Dense::Path.new(path)
+ pa = Dense::Path.make(path)
r = pa.gather(o).partition(&:first)
if r[0].empty?
return pa.narrow(
@@ -30,22 +30,22 @@
pa.narrow(r[0].collect { |e| e[2][e[3]] })
end
def set(o, path, value)
- Dense::Path.new(path)
+ Dense::Path.make(path)
.gather(o)
.each { |hit|
fail_miss_error(path, hit) if hit[0] == false
hit[2][hit[3]] = value }
value
end
def unset(o, path, nofail=false)
- pa = Dense::Path.new(path)
+ pa = Dense::Path.make(path)
hits = pa.gather(o)
hits.each { |h| fail miss_error(path, h) unless h[0] } unless nofail
r = hits
@@ -60,11 +60,11 @@
pa.narrow(r)
end
def insert(o, path, value)
- Dense::Path.new(path)
+ Dense::Path.make(path)
.gather(o)
.each { |hit|
fail_miss_error(path, hit) if hit[0] == false
if hit[2].is_a?(Array)
hit[2].insert(hit[3], value)
@@ -75,20 +75,20 @@
value
end
def has_key?(o, path)
- !! Dense::Path.new(path).gather(o).find { |m| m[0] }
+ !! Dense::Path.make(path).gather(o).find { |m| m[0] }
end
def path(path)
- Dense::Path.new(path)
+ Dense::Path.make(path)
end
def gather(o, path)
- Dense::Path.new(path).gather(o)
+ Dense::Path.make(path).gather(o)
end
protected
module DenseError