geode 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/geode.rb +30 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c0e61d7408e1968eef5ce7ca4f044ba24ad8c60556f0e447fc4c5053b33e3696
|
4
|
+
data.tar.gz: a71f1f43281f5c207b7172ce80317e91608f18c226ec707a4a485c27b3ddc916
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 85b0de5f20e66ab77782b0a9db839e2888c8f3258335461e20595e8effcab0399b612c1ef53c0cebb34572b7c1d533394dc27a2249919f76570cdb36ad88076a
|
7
|
+
data.tar.gz: aacbdfd3ae417f3b5d17c8a88ff21975604c33e875a16157a6614eb2418971feefd7bc17cacb644dcd13afcd9115279b910c37d1e78a848113a3c06609d6ade9
|
data/lib/geode.rb
CHANGED
@@ -10,10 +10,39 @@ module Geode
|
|
10
10
|
|
11
11
|
# "Open" the store for reading and/or writing.
|
12
12
|
# @yield a block which receives `table` as its sole parameter
|
13
|
-
# @yieldparam table [Hash] The table
|
13
|
+
# @yieldparam table [Hash] The store's table. Changes to this Hash will
|
14
|
+
# be persisted in the store
|
15
|
+
# When in doubt, use this method.
|
16
|
+
# @example
|
17
|
+
# "store.open { |table| table[:key] = 5 }"
|
18
|
+
# @example
|
19
|
+
# "store.open { |table| table[:key] } #=> 5"
|
14
20
|
# @return [Object] The return value of the block
|
15
21
|
def open
|
16
22
|
raise NotImplementedError
|
17
23
|
end
|
24
|
+
|
25
|
+
# "Peek" inside the store, returning a copy of its table.
|
26
|
+
# Changes to this copy will NOT be persisted in the store.
|
27
|
+
# Use this if you simply want to view the store's table.
|
28
|
+
# @example
|
29
|
+
# "store.peek.key?(:test) #=> false"
|
30
|
+
# @return [Hash] A copy of the store's table
|
31
|
+
def peek
|
32
|
+
open(&:itself)
|
33
|
+
end
|
34
|
+
|
35
|
+
# Retrieve the object at `key` from the store.
|
36
|
+
# This is implemented using `#peek` and therefore
|
37
|
+
# changes to the object returned by this method will NOT
|
38
|
+
# be persisted in the store.
|
39
|
+
# Use this if you simply need to fetch a value from the store.
|
40
|
+
# @example
|
41
|
+
# "store[:key] #=> 5"
|
42
|
+
# @param key [Object] The key to look up
|
43
|
+
# @return [Object] The object at `key`
|
44
|
+
def [](key)
|
45
|
+
peek[key]
|
46
|
+
end
|
18
47
|
end
|
19
48
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: geode
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- biqqles
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-10-
|
11
|
+
date: 2021-10-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pg
|