prop 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/prop.rb +6 -10
- data/prop.gemspec +1 -1
- data/test/test_prop.rb +2 -2
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.3
|
data/lib/prop.rb
CHANGED
@@ -26,15 +26,15 @@ class Prop
|
|
26
26
|
raise RuntimeError.new("Invalid interval setting") unless defaults[:interval].to_i > 0
|
27
27
|
|
28
28
|
define_prop_class_method "throttle_#{handle}!" do |*args|
|
29
|
-
throttle!(sanitized_prop_options(handle
|
29
|
+
throttle!(sanitized_prop_options([ handle ] + args, defaults))
|
30
30
|
end
|
31
31
|
|
32
32
|
define_prop_class_method "throttle_#{handle}?" do |*args|
|
33
|
-
throttle?(sanitized_prop_options(handle
|
33
|
+
throttle?(sanitized_prop_options([ handle ] + args, defaults))
|
34
34
|
end
|
35
35
|
|
36
36
|
define_prop_class_method "reset_#{handle}" do |*args|
|
37
|
-
reset(sanitized_prop_options(handle
|
37
|
+
reset(sanitized_prop_options([ handle ] + args, defaults))
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
@@ -71,13 +71,9 @@ class Prop
|
|
71
71
|
end
|
72
72
|
|
73
73
|
# Sanitizes the option set and sets defaults
|
74
|
-
def sanitized_prop_options(
|
75
|
-
|
76
|
-
key
|
77
|
-
|
78
|
-
options = { :key => key, :threshold => defaults[:threshold].to_i, :interval => defaults[:interval].to_i }
|
79
|
-
options = options.merge(args.last) if args.last.is_a?(Hash)
|
80
|
-
options
|
74
|
+
def sanitized_prop_options(args, defaults)
|
75
|
+
options = args.last.is_a?(Hash) ? args.pop : {}
|
76
|
+
{ :key => normalize_cache_key(args), :threshold => defaults[:threshold].to_i, :interval => defaults[:interval].to_i }.merge(options)
|
81
77
|
end
|
82
78
|
|
83
79
|
# Simple key expansion only supports arrays and primitives
|
data/prop.gemspec
CHANGED
data/test/test_prop.rb
CHANGED
@@ -46,8 +46,8 @@ class TestProp < Test::Unit::TestCase
|
|
46
46
|
assert_equal 2, Prop.throttle_hello_there!(5)
|
47
47
|
assert_equal 1, Prop.throttle_hello_there!('mister')
|
48
48
|
assert_equal 2, Prop.throttle_hello_there!('mister')
|
49
|
-
assert_equal 1, Prop.throttle_hello_there!(
|
50
|
-
assert_equal 2, Prop.throttle_hello_there!(
|
49
|
+
assert_equal 1, Prop.throttle_hello_there!('mister', 5)
|
50
|
+
assert_equal 2, Prop.throttle_hello_there!('mister', 5)
|
51
51
|
end
|
52
52
|
|
53
53
|
should "not shadow undefined methods" do
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 3
|
10
|
+
version: 0.3.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Morten Primdahl
|