norton 0.0.2 → 0.0.4

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: a890e200767cb913b8bc0824fdc136c58a40b4b5
4
- data.tar.gz: dd7aeb45e6d96b162575fc20dc64ea0e357ff364
3
+ metadata.gz: c3d218b2bff9e0a867ec67221c1eeb8a2759fbe7
4
+ data.tar.gz: 168813296e582bb141da14a8e09d5fca605bbe68
5
5
  SHA512:
6
- metadata.gz: a3dee1ab4a58f39edc79359aad0a944a84deb4ed1ee11810bccbe723331660a2555be585a47e8e1aa4d46248e97b1dac0e39e7ef79b9dd4398be5c1da1e2a67c
7
- data.tar.gz: 633fe0fc1c20d5458985cd7d948c519d1dcff6d254631e66c8573a11ddc7bc782aad97bd3f057be9f7f95355d0752d6a92d388e0efd2da12bced38ccfbd2e5da
6
+ metadata.gz: 9239c23469e7b94fbee668808b9dc742ad6e4fb8d833d0d140f291a004e00405e24a2c94d41b2d46abdc959f790aa851fd31e688e63ae215a330b4ea1fea1a90
7
+ data.tar.gz: fa2a530be3592c7c9eb9b1f0b80a5f2eb9849e8131f2a19e6a10f56fdf1dfcaca9ced81ea92bc30f043a22ef8b985b94275bccbfe5d7ca53cab091857dd3e5e2
@@ -9,7 +9,7 @@ module Norton
9
9
  # @param touches={} [type] [description]
10
10
  #
11
11
  # @return [type] [description]
12
- def counter(name, options, &blk)
12
+ def counter(name, options={}, &blk)
13
13
  define_method(name) do
14
14
  Norton.redis.with do |conn|
15
15
  conn.get("#{self.class.to_s.pluralize.downcase}:#{self.id}:#{name}").try(:to_i) || 0
@@ -12,8 +12,15 @@ module Norton
12
12
  def timestamp(name, touches={})
13
13
  define_method(name) do
14
14
  Norton.redis.with do |conn|
15
- conn.get("#{self.class.to_s.pluralize.downcase}:#{self.id}:#{name}").try(:to_i) || Time.now.to_i
15
+ ts = conn.get("#{self.class.to_s.pluralize.downcase}:#{self.id}:#{name}").try(:to_i)
16
+
17
+ if ts.nil?
18
+ ts = Time.now.to_i
19
+ conn.set("#{self.class.to_s.pluralize.downcase}:#{self.id}:#{name}", ts)
20
+ end
16
21
  end
22
+
23
+ ts
17
24
  end
18
25
 
19
26
  define_method("touch_#{name}") do
@@ -1,3 +1,3 @@
1
1
  module Norton
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: norton
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Larry Zhao
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-17 00:00:00.000000000 Z
11
+ date: 2015-03-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis