prop 0.3.2 → 0.3.3

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.
Files changed (5) hide show
  1. data/VERSION +1 -1
  2. data/lib/prop.rb +6 -10
  3. data/prop.gemspec +1 -1
  4. data/test/test_prop.rb +2 -2
  5. metadata +3 -3
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.2
1
+ 0.3.3
@@ -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, args, defaults))
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, args, defaults))
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, args, defaults))
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(handle, args, defaults)
75
- key = handle.to_s
76
- key << "/#{normalize_cache_key(args.first)}" if args.first
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
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{prop}
8
- s.version = "0.3.2"
8
+ s.version = "0.3.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Morten Primdahl"]
@@ -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!(['mister', 5])
50
- assert_equal 2, Prop.throttle_hello_there!(['mister', 5])
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: 23
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 2
10
- version: 0.3.2
9
+ - 3
10
+ version: 0.3.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Morten Primdahl