redis-classy 2.2.0 → 2.3.0

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
  SHA1:
3
- metadata.gz: c0b3f159d870fa11917933fad909718b6c25e238
4
- data.tar.gz: 261b90d914fb16f5d8ba44465e94fa7fc158b7f4
3
+ metadata.gz: cbaa4165750c1d833bd0dac513a327659cc03c72
4
+ data.tar.gz: 7ad146371f45610ef1452c6c753633365226ddb2
5
5
  SHA512:
6
- metadata.gz: 3777edbb75e8bebf54fda67050533cd440601ee549b92622784cc6cf8233b4374e026fddd7e3ef3107d5b62bf8027293e52304812b33e892957c0de28089fef2
7
- data.tar.gz: cc3739cd888b848d71b7e5b828c50585036e34c0dc0a68abc1123d1e18e0c7bac8d99f33578698c798c0d7c5fed1289d5e3f00d5d61e9520c9737eb88dd8db72
6
+ metadata.gz: 1369ce3fba96daf02ab259c6347f634a3783cb1cd1572dad360b4c0ef02a1944bfbc7b37489776b8dfbb3e02bc815dfa77d69232f250d02c621ea17cc34ec55a
7
+ data.tar.gz: d1d1aa2f8cbf21f78a4e7ef85942cb585764c468e05ff97d378c8e2899520d6d804c7664c236fe85bc2ddc6a9a0143a7d3aa519c5a121b64ed0ec17f1374a24a
data/lib/redis_classy.rb CHANGED
@@ -15,26 +15,13 @@ class RedisClassy
15
15
  def redis
16
16
  @redis ||= begin
17
17
  if self == RedisClassy
18
- nil
18
+ raise Error.new('RedisClassy.redis must be assigned first')
19
19
  else
20
- raise Error.new('RedisClassy.redis is not assigned') if RedisClassy.redis.nil?
21
20
  Redis::Namespace.new(self.name, redis: RedisClassy.redis)
22
21
  end
23
22
  end
24
23
  end
25
24
 
26
- def singletons(*args)
27
- args.each do |key|
28
- define_singleton_method(key) do
29
- new key
30
- end
31
- end
32
- end
33
-
34
- def singleton
35
- @singleton = true
36
- end
37
-
38
25
  def on(key)
39
26
  new(key)
40
27
  end
@@ -46,6 +33,24 @@ class RedisClassy
46
33
  super
47
34
  end
48
35
  end
36
+
37
+ # Singletons
38
+
39
+ attr_reader :singletons_keys
40
+
41
+ def singletons(*args)
42
+ args.each do |key|
43
+ @singletons_keys ||= []
44
+ @singletons_keys << key
45
+ define_singleton_method(key) do
46
+ new key
47
+ end
48
+ end
49
+ end
50
+
51
+ def singleton
52
+ @singleton = true
53
+ end
49
54
  end
50
55
 
51
56
  # Instance methods
@@ -1,3 +1,3 @@
1
1
  class RedisClassy
2
- VERSION = '2.2.0'
2
+ VERSION = '2.3.0'
3
3
  end
@@ -116,6 +116,8 @@ describe RedisClassy do
116
116
  Stats.average.set ages.inject(:+)/ages.size
117
117
  expect(Stats.median.get).to eq('24')
118
118
  expect(Stats.average.get).to eq('25')
119
+ expect(Stats.keys.map(&:to_sym)).to eq([:median, :average])
120
+ expect(Stats.singletons_keys).to eq([:median, :average])
119
121
  end
120
122
 
121
123
  it 'handles multiple key commands' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redis-classy
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kenn Ejima
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-24 00:00:00.000000000 Z
11
+ date: 2016-10-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis-namespace
@@ -107,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
107
107
  version: '0'
108
108
  requirements: []
109
109
  rubyforge_project:
110
- rubygems_version: 2.2.2
110
+ rubygems_version: 2.5.1
111
111
  signing_key:
112
112
  specification_version: 4
113
113
  summary: Class-style namespace prefixing for Redis