Module: Chron
- Defined in:
- lib/chron.rb,
lib/chron/version.rb
Defined Under Namespace
Modules: Observable
Classes: ExistingObservable, Job, UnknownObservable, UnknownObservation
Constant Summary
collapse
- OBSERVABLES =
{}
- POLLING_RANGE =
-> { (Time.current - POLLING_WINDOW)..(Time.current + POLLING_WINDOW) }
- POLLING_WINDOW =
5 * 60
- VERSION =
"0.1.1"
Class Method Summary
collapse
Class Method Details
.add_observable_resource(class_name) ⇒ Object
11
12
13
|
# File 'lib/chron.rb', line 11
def self.add_observable_resource(class_name)
OBSERVABLES[class_name.to_s] = {}
end
|
.add_observation(class_name, column, block) ⇒ Object
27
28
29
30
31
|
# File 'lib/chron.rb', line 27
def self.add_observation(class_name, column, block)
observable = OBSERVABLES[class_name]
raise ExistingObservable if observable[column].present?
observable[column] = block
end
|
.observable_resources ⇒ Object
7
8
9
|
# File 'lib/chron.rb', line 7
def self.observable_resources
OBSERVABLES.keys
end
|
.observables_for(class_name) ⇒ Object
15
16
17
18
19
|
# File 'lib/chron.rb', line 15
def self.observables_for(class_name)
observable = OBSERVABLES[class_name]
raise UnknownObservable if observable.blank?
observable.keys
end
|
.observation(class_name, column) ⇒ Object
21
22
23
24
25
|
# File 'lib/chron.rb', line 21
def self.observation(class_name, column)
observation = OBSERVABLES[class_name][column]
raise UnknownObservation if observation.blank?
observation
end
|