lib/ruote/storage/hash_storage.rb in ruote-2.1.3 vs lib/ruote/storage/hash_storage.rb in ruote-2.1.4
- old
+ new
@@ -68,11 +68,11 @@
end
doc['put_at'] = Ruote.now_to_utc_s
doc['_rev'] = doc['_rev'] + 1
- (@h[doc['type']] ||= {})[doc['_id']] = Rufus::Json.dup(doc)
+ @h[doc['type']][doc['_id']] = Rufus::Json.dup(doc)
nil
end
end
@@ -126,10 +126,17 @@
docs
end
end
end
+ # Returns a sorted list of all the ids for a given type.
+ #
+ def ids (type)
+
+ @h[type].keys.sort
+ end
+
def purge!
@h = %w[
variables
@@ -147,10 +154,20 @@
}
@h['configurations']['engine'] = @options
end
+ def add_type (type)
+
+ @h[type] = {}
+ end
+
+ def purge_type! (type)
+
+ @h[type] = {}
+ end
+
def dump (type)
s = "=== #{type} ===\n"
@h[type].inject(s) do |s1, (k, v)|
@@ -158,14 +175,9 @@
s1 << "#{k} :\n"
v.keys.sort.inject(s1) do |s2, k1|
s2 << " #{k1} => #{v[k1].inspect}\n"
end
end
- end
-
- def add_test_type (type)
-
- @h[type] = {}
end
end
end