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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/geode.rb +30 -1
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7c1357dd8aadd830b705e45dcee476fdd473222574269373691ff6f91964da95
4
- data.tar.gz: 1cc2d1a5129a238c25d89dc75a33c9edacdc79b45d9f7768ffc5912c4068e97d
3
+ metadata.gz: c0e61d7408e1968eef5ce7ca4f044ba24ad8c60556f0e447fc4c5053b33e3696
4
+ data.tar.gz: a71f1f43281f5c207b7172ce80317e91608f18c226ec707a4a485c27b3ddc916
5
5
  SHA512:
6
- metadata.gz: 982b9ab60e0e287bdc79b431074ac3a65afffe306d49e79d99add358a3401babc36ba2a77dca01d92b0f46f1f72c2ce052d3eb52d4fec1a147c7ce70f966e4dc
7
- data.tar.gz: 33237585799704b24e0634335d5a84a9cc75ec95340b7d24be6b1befe5a671f27884a82cbfb3099ed1a5a3d5218b3b3f127ae4aea52ec0127d0f8b9c1af7fa34
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 belonging to `@name`
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.3.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-15 00:00:00.000000000 Z
11
+ date: 2021-10-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pg