norton 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/lib/norton/timestamp.rb +9 -5
- data/lib/norton/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 20422c62cc84a467cf851caf000e326cad7a591b
|
4
|
+
data.tar.gz: bfef0b9673d1b27f2daa4b5660a6180860767d42
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f70c087bb056a4f11c9d19216653b12b3699df906b05b06814206d08688bb72a0615beb052956a24cc190ad29374e8ceb5fec64b021850cdbe4876b2534d5f05
|
7
|
+
data.tar.gz: eefb0c5a1ed7201a01acf3a9aecc3d466fd964c90d9d2925633040e44dfa1abd50f71e30a6808458de04afa074272c07bce57a64855fcb0b9365dd664e3e1ce2
|
data/Gemfile
CHANGED
data/lib/norton/timestamp.rb
CHANGED
@@ -9,7 +9,7 @@ module Norton
|
|
9
9
|
# @param touches={} [type] [description]
|
10
10
|
#
|
11
11
|
# @return [type] [description]
|
12
|
-
def timestamp(name,
|
12
|
+
def timestamp(name, options={})
|
13
13
|
define_method(name) do
|
14
14
|
ts = nil
|
15
15
|
|
@@ -27,17 +27,21 @@ module Norton
|
|
27
27
|
|
28
28
|
define_method("touch_#{name}") do
|
29
29
|
Norton.redis.with do |conn|
|
30
|
-
|
30
|
+
if options[:digits].present? && options[:digits] == 13
|
31
|
+
conn.set("#{self.class.to_s.pluralize.downcase}:#{self.id}:#{name}", (Time.now.to_f * 1000).to_i)
|
32
|
+
else
|
33
|
+
conn.set("#{self.class.to_s.pluralize.downcase}:#{self.id}:#{name}", Time.now.to_i)
|
34
|
+
end
|
31
35
|
end
|
32
36
|
end
|
33
37
|
|
34
38
|
# Add callback
|
35
|
-
unless
|
36
|
-
|
39
|
+
unless options[:touch_on].empty?
|
40
|
+
options[:touch_on].each do |callback, condition|
|
37
41
|
self.send callback, proc{ if instance_eval(&condition) then instance_eval("touch_#{name}") end }
|
38
42
|
end
|
39
43
|
end
|
40
44
|
end
|
41
45
|
end
|
42
46
|
end
|
43
|
-
end
|
47
|
+
end
|
data/lib/norton/version.rb
CHANGED
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.
|
4
|
+
version: 0.0.9
|
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-
|
11
|
+
date: 2015-06-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis
|
@@ -164,7 +164,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
164
164
|
version: '0'
|
165
165
|
requirements: []
|
166
166
|
rubyforge_project:
|
167
|
-
rubygems_version: 2.4.
|
167
|
+
rubygems_version: 2.4.7
|
168
168
|
signing_key:
|
169
169
|
specification_version: 4
|
170
170
|
summary: Provide simple helpers on persist values in redis for performance. Works
|