prop 2.1.0 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/prop.rb +1 -1
- data/lib/prop/limiter.rb +4 -4
- 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: ea6891496856bc79f150b138e0c771f613d2214d
|
4
|
+
data.tar.gz: 93efa5eb27652eb0c8bb907f3d7439bd5d4f8260
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2690c81fcd19c6c292e7782f15347e0fcb80f3e60d19e34c073e4e0b4b7b20d7c83ca9eef7e9c0ffcf8bf87f42270171a7f96c68cddabff130e2ac88859ad01f
|
7
|
+
data.tar.gz: aa0ae06e67099a0b782404aa559c45af195e2f51967a1004d71dea15d98d3f88341ca47833f337a2f8b86a52b6b89dab9eac7b0df548fd8a67ccc4876d5bf405
|
data/lib/prop.rb
CHANGED
data/lib/prop/limiter.rb
CHANGED
@@ -70,9 +70,10 @@ module Prop
|
|
70
70
|
# (optional) a block of code that this throttle is guarding
|
71
71
|
#
|
72
72
|
# Returns true if the threshold for this handle has been reached, else returns false
|
73
|
-
def throttle(handle, key = nil, options = {}
|
73
|
+
def throttle(handle, key = nil, options = {})
|
74
74
|
options, cache_key = prepare(handle, key, options)
|
75
|
-
_throttle(handle, key, cache_key, options
|
75
|
+
throttled = _throttle(handle, key, cache_key, options).first
|
76
|
+
block_given? && !throttled ? yield : throttled
|
76
77
|
end
|
77
78
|
|
78
79
|
# Public: Records a single action for the given handle/key combination.
|
@@ -86,7 +87,7 @@ module Prop
|
|
86
87
|
# Returns the value of the block if given a such, otherwise the current count of the throttle
|
87
88
|
def throttle!(handle, key = nil, options = {}, &block)
|
88
89
|
options, cache_key = prepare(handle, key, options)
|
89
|
-
throttled, counter = _throttle(handle, key, cache_key, options
|
90
|
+
throttled, counter = _throttle(handle, key, cache_key, options)
|
90
91
|
|
91
92
|
if throttled
|
92
93
|
raise Prop::RateLimited.new(options.merge(
|
@@ -158,7 +159,6 @@ module Prop
|
|
158
159
|
|
159
160
|
[result, counter]
|
160
161
|
else
|
161
|
-
yield if block_given?
|
162
162
|
[false, counter]
|
163
163
|
end
|
164
164
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Morten Primdahl
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|