Module: SlowDown
- Defined in:
- lib/slow_down.rb,
lib/slow_down/group.rb,
lib/slow_down/version.rb,
lib/slow_down/configuration.rb,
lib/slow_down/strategy/base.rb,
lib/slow_down/strategy/linear.rb,
lib/slow_down/strategy/fibonacci.rb,
lib/slow_down/strategy/inverse_exponential.rb
Defined Under Namespace
Modules: Strategy
Classes: Configuration, Group
Constant Summary
collapse
- Timeout =
Class.new(StandardError)
- ConfigError =
Class.new(StandardError)
- VERSION =
"0.2.1"
Class Method Summary
collapse
Class Method Details
.config(group_name = :default) ⇒ Object
15
16
17
18
19
20
21
|
# File 'lib/slow_down.rb', line 15
def config(group_name = :default)
group = Group.find_or_create(group_name)
group.config.tap do |c|
yield(c) if block_given?
end
end
|
.find_or_create_group(*args) ⇒ Object
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/slow_down.rb', line 41
def find_or_create_group(*args)
if args[0].is_a?(Hash)
group_name = :default
options = args[0]
else
group_name = args[0] || :default
options = args[1] || {}
end
Group.find_or_create(group_name, options)
end
|
.free?(*args) ⇒ Boolean
31
32
33
|
# File 'lib/slow_down.rb', line 31
def free?(*args)
find_or_create_group(*args).free?
end
|
.groups ⇒ Object
23
24
25
|
# File 'lib/slow_down.rb', line 23
def groups
Group.all
end
|
.reset(group_name = :default) ⇒ Object
35
36
37
38
39
|
# File 'lib/slow_down.rb', line 35
def reset(group_name = :default)
if group = Group.find(group_name)
group.reset
end
end
|
.run(*args, &block) ⇒ Object
27
28
29
|
# File 'lib/slow_down.rb', line 27
def run(*args, &block)
find_or_create_group(*args).run(&block)
end
|