couchbase-structures 0.0.9 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
@@ -21,9 +21,23 @@ module CouchbaseStructures
|
|
21
21
|
|
22
22
|
@key = key
|
23
23
|
@list_key = "#{key}::sorted_list"
|
24
|
-
initialize_document(@list_key, { :sorted_list => [], :last_updated => Time.now.utc.to_i })
|
24
|
+
initialize_document(@list_key, { :sorted_list => [], :last_updated => Time.now.utc.to_i, :user_key => @key })
|
25
25
|
self
|
26
26
|
end
|
27
|
+
|
28
|
+
def inspect(html=false)
|
29
|
+
if html
|
30
|
+
str = "["
|
31
|
+
self.items.each do |item|
|
32
|
+
str += "<br /> " + item.inspect
|
33
|
+
end
|
34
|
+
str += "<br />]"
|
35
|
+
|
36
|
+
return "<strong>key</strong> = #{@key} <br /><strong>items</strong> = #{str}"
|
37
|
+
else
|
38
|
+
return items.inspect
|
39
|
+
end
|
40
|
+
end
|
27
41
|
|
28
42
|
def add(value)
|
29
43
|
doc = get_document(@list_key)
|
@@ -50,5 +64,9 @@ module CouchbaseStructures
|
|
50
64
|
doc = get_document(@list_key)
|
51
65
|
doc["sorted_list"].size
|
52
66
|
end
|
67
|
+
|
68
|
+
def delete
|
69
|
+
delete_document(@list_key)
|
70
|
+
end
|
53
71
|
end
|
54
72
|
end
|