prop 2.1.0 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/prop.rb +1 -1
  3. data/lib/prop/limiter.rb +4 -4
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7f2dd0390e5bbcf9ae63a8f2955d271b307b4d50
4
- data.tar.gz: 66836a3d9ccb4189bc45edd01a94714d051eb620
3
+ metadata.gz: ea6891496856bc79f150b138e0c771f613d2214d
4
+ data.tar.gz: 93efa5eb27652eb0c8bb907f3d7439bd5d4f8260
5
5
  SHA512:
6
- metadata.gz: 8eab2e9e05c2a3c7e9e7b4cc84c483f532eccfbf86559c10f44df4dc03f6f267a5054f55a9a82f1fe9fe22744841638520dcb98e3d31063e441c04c8cae06b7f
7
- data.tar.gz: dbc80fce9d3466f41194c4595dd4e3847d82879225c0ae8c5bae0a3903dfc8345792b36ce8447a7f3cc31cdf54a8900ab222e5e1dc3f9bf302ab615da5e8bb7a
6
+ metadata.gz: 2690c81fcd19c6c292e7782f15347e0fcb80f3e60d19e34c073e4e0b4b7b20d7c83ca9eef7e9c0ffcf8bf87f42270171a7f96c68cddabff130e2ac88859ad01f
7
+ data.tar.gz: aa0ae06e67099a0b782404aa559c45af195e2f51967a1004d71dea15d98d3f88341ca47833f337a2f8b86a52b6b89dab9eac7b0df548fd8a67ccc4876d5bf405
@@ -2,7 +2,7 @@ require "prop/limiter"
2
2
  require "forwardable"
3
3
 
4
4
  module Prop
5
- VERSION = "2.1.0"
5
+ VERSION = "2.1.1"
6
6
 
7
7
  # Short hand for accessing Prop::Limiter methods
8
8
  class << self
@@ -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 = {}, &block)
73
+ def throttle(handle, key = nil, options = {})
74
74
  options, cache_key = prepare(handle, key, options)
75
- _throttle(handle, key, cache_key, options, &block).first
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, &block)
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.0
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-22 00:00:00.000000000 Z
11
+ date: 2016-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake