active_cabinet 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6d657eb6430a9e6b83a734d786d607b515947e38e435c71e5e7ee4f10e5b7a4b
4
- data.tar.gz: 425dd03d6a76f31526e9e56b06a2c05971328fdae786516bcb969084367aaa4c
3
+ metadata.gz: b61d0603a2ee6d70ca64a73cdf0081d869190d37b7bc3ba4795f79eb69389021
4
+ data.tar.gz: fefcaba2831cdc000efbed76754714af54b71b06221bcd2818e81acf78d12c2b
5
5
  SHA512:
6
- metadata.gz: 8218b482cc51bb181224beeda6b8eb24acdcb6ff29eeb5bcae1df67ef22ed2a2c1ca4cf6e9798078034402fdae8d06b498337be4748ebf97fea26b9a7f0bac52
7
- data.tar.gz: 478f69291f74ea3422771d31cf9ff91d587457293b4d2b5188df8542ff01a8bc2ce06f1faa19922d84d310a653a17a3e96e7557de3aa89122f05550fae652a10
6
+ metadata.gz: 4ff91224eabf6843fd471864fbcf235cae80970f689392ca4ee07936d5a4708489c2e3e3eec7c11407d6dee615faf341ee38196781e7989cbc731bc8c3240b85
7
+ data.tar.gz: a6ba9e9921e5b11701489d75f786a09759ad39a76dba75fcd135745305a853ff46d487016e6c640640700259b99b138a528122e2197d39a37f25c15b7f490994
@@ -112,9 +112,39 @@ class ActiveCabinet
112
112
  end
113
113
  alias [] find
114
114
 
115
+ # Yields each record to the given block.
116
+ #
117
+ # @yieldparam [Object] record all record instances.
118
+ def each
119
+ cabinet.each_value do |attributes|
120
+ yield new(attributes)
121
+ end
122
+ end
123
+
124
+ # Returns the first record.
125
+ #
126
+ # @return [Object] the record.
127
+ def first
128
+ find keys.first
129
+ end
130
+
131
+ # Returns the last record.
132
+ #
133
+ # @return [Object] the record.
134
+ def last
135
+ find keys.last
136
+ end
137
+
138
+ # Returns a random racord.
139
+ #
140
+ # @return [Object] the record.
141
+ def random
142
+ find keys.sample
143
+ end
144
+
115
145
  # @!group Deleting Records
116
146
 
117
- # Deletes a record matching the +id+
147
+ # Deletes a record matching the +id+.
118
148
  #
119
149
  # @param [String] id the record ID.
120
150
  # @return [Boolean] +true+ on success, +false+ otherwise.
@@ -1,3 +1,3 @@
1
1
  class ActiveCabinet
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_cabinet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Danny Ben Shitrit
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-10 00:00:00.000000000 Z
11
+ date: 2020-09-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hash_cabinet