fake_go_up 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/fake_go_up/item.rb +27 -8
- data/lib/fake_go_up/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 98e032f39b7d3eb4958b2de9dc91c44441ee73af
|
4
|
+
data.tar.gz: 25d61e1a017b9db5da6143c85d497f0baca1c2b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2025e0d97da18cb3bff3ba4707403bf3f4a3be38caa63e42da19b8bf5124f29668cf8e7dff0a5a71370344628efba2e12ea9b8465d873ce12bac9bd552642d0c
|
7
|
+
data.tar.gz: 9e81a61e9c9ec12a5edb0509278b2e529ad59620a76fbcb7ea2563f741f6791e569fefd436c8538bafab749be0516c99bd2c61b6077ec7f7d868ff089c8f85a4
|
data/lib/fake_go_up/item.rb
CHANGED
@@ -1,26 +1,45 @@
|
|
1
1
|
module FakeGoUp
|
2
2
|
class Item
|
3
|
-
|
4
|
-
|
5
|
-
@@
|
3
|
+
attr_reader :count
|
4
|
+
REDIS_KEY = "fake_go_up:items"
|
5
|
+
@@instance_collector = {}
|
6
6
|
|
7
7
|
def initialize(id = 1)
|
8
8
|
@id = id
|
9
9
|
@count = 0
|
10
|
+
@@instance_collector[id] = self
|
10
11
|
end
|
11
12
|
|
12
13
|
def id
|
13
14
|
@id
|
14
15
|
end
|
15
16
|
|
17
|
+
def count= (c)
|
18
|
+
FakeGoUp.redis.hset(FakeGoUp::Item::REDIS_KEY, id, c)
|
19
|
+
@count = c
|
20
|
+
end
|
21
|
+
|
16
22
|
def self.find_by_id(id)
|
17
|
-
|
23
|
+
id = id.to_i
|
24
|
+
|
25
|
+
instance = self.instances[id]
|
26
|
+
return instance if instance
|
27
|
+
|
28
|
+
count = FakeGoUp.redis.hget(FakeGoUp::Item::REDIS_KEY, id).to_i
|
29
|
+
instance = self.new(id)
|
30
|
+
instance.count = count
|
31
|
+
instance
|
18
32
|
end
|
19
33
|
|
20
34
|
def self.create(id)
|
21
|
-
|
22
|
-
|
23
|
-
|
35
|
+
id = id.to_i
|
36
|
+
|
37
|
+
FakeGoUp.redis.hset(FakeGoUp::Item::REDIS_KEY, id, 0)
|
38
|
+
new(id)
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.instances
|
42
|
+
@@instance_collector
|
24
43
|
end
|
25
44
|
end
|
26
|
-
end
|
45
|
+
end
|
data/lib/fake_go_up/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fake_go_up
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- xuxiangyang
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-11-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pid_lock
|