Class: Gamifier::ActivityDefinition
- Inherits:
-
Model
- Object
- OpenStruct
- Model
- Gamifier::ActivityDefinition
show all
- Defined in:
- lib/gamifier/models/activity_definition.rb
Instance Attribute Summary
Attributes inherited from Model
#engine
Instance Method Summary
collapse
Methods inherited from Model
#_id, #attributes, #destroy, #encode, #new?, #path, #payload_for_submission, #replace_if_successful, #save, #update_attributes
#container, #mutable_attributes, #path, #reset!, #special_attributes, #store_or_get
Instance Method Details
#limit(n_times, over_time) ⇒ Object
6
7
8
9
10
11
|
# File 'lib/gamifier/models/activity_definition.rb', line 6
def limit(n_times, over_time)
self.enable_rate_limiting = true
self.bucket_max_capacity = n_times
self.bucket_drain_rate = n_times.to_f / over_time.to_f
self
end
|
#limit_once_per_day ⇒ Object
21
22
23
|
# File 'lib/gamifier/models/activity_definition.rb', line 21
def limit_once_per_day
limit_per_day 1
end
|
#limit_once_per_week ⇒ Object
25
26
27
|
# File 'lib/gamifier/models/activity_definition.rb', line 25
def limit_once_per_week
limit_per_week 1
end
|
#limit_per_day(times_per_day) ⇒ Object
13
14
15
|
# File 'lib/gamifier/models/activity_definition.rb', line 13
def limit_per_day(times_per_day)
limit(times_per_day, 24.0)
end
|
#limit_per_week(times_per_week) ⇒ Object
17
18
19
|
# File 'lib/gamifier/models/activity_definition.rb', line 17
def limit_per_week(times_per_week)
limit(times_per_week, 24.0 * 7.0)
end
|