aiaio-active_resource_throttle 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
@@ -72,7 +72,7 @@ module ActiveResourceThrottle
|
|
72
72
|
# Interrupts connection requests only if
|
73
73
|
# throttle is engaged.
|
74
74
|
def connection_with_throttle(refresh = false)
|
75
|
-
throttle_connection_request if throttle_engaged?
|
75
|
+
throttle_connection_request if throttle_engaged? && base_class?
|
76
76
|
connection_without_throttle(refresh)
|
77
77
|
end
|
78
78
|
|
@@ -107,6 +107,13 @@ module ActiveResourceThrottle
|
|
107
107
|
throttle_interval.to_i > 0 && throttle_request_limit.to_i > 0
|
108
108
|
end
|
109
109
|
|
110
|
+
# Is this the class from which a connection will originate?
|
111
|
+
# See ActiveResource::Base.connection method for details.
|
112
|
+
def base_class?
|
113
|
+
defined?(@connection) || superclass == Object
|
114
|
+
end
|
115
|
+
|
116
|
+
|
110
117
|
end
|
111
118
|
|
112
119
|
# Callback invoked when ActiveResourceThrottle
|
@@ -1,11 +1,16 @@
|
|
1
|
-
|
1
|
+
module Hash::ValidKeys
|
2
2
|
def assert_valid_keys(*valid_keys)
|
3
3
|
unknown_keys = keys - valid_keys
|
4
4
|
raise ArgumentError, "Invalid option(s): #{unknown_keys.join(", ")}" unless unknown_keys.empty?
|
5
5
|
end
|
6
|
-
|
6
|
+
end
|
7
|
+
|
8
|
+
class Hash
|
9
|
+
include ValidKeys unless defined?(ActiveSupport)
|
10
|
+
|
7
11
|
def assert_required_keys(*required_keys)
|
8
12
|
missing_keys = required_keys.select {|key| !keys.include?(key)}
|
9
13
|
raise ArgumentError, "Missing required option(s): #{missing_keys.join(", ")}" unless missing_keys.empty?
|
10
14
|
end
|
11
15
|
end
|
16
|
+
|