Class: Observed::System
- Inherits:
-
Object
- Object
- Observed::System
- Defined in:
- lib/observed/system.rb
Instance Method Summary collapse
- #config ⇒ Object
- #config=(config) ⇒ Object
-
#initialize(args = {}) ⇒ System
constructor
A new instance of System.
- #now ⇒ Object
- #run(observation_name = nil, data = nil, options = nil) ⇒ Object
Constructor Details
#initialize(args = {}) ⇒ System
Returns a new instance of System.
7 8 9 10 11 |
# File 'lib/observed/system.rb', line 7 def initialize(args={}) @config = args[:config] if args[:config] @logger = args[:logger] if args[:logger] @context = args[:context] end |
Instance Method Details
#config ⇒ Object
17 18 19 |
# File 'lib/observed/system.rb', line 17 def config @config end |
#config=(config) ⇒ Object
13 14 15 |
# File 'lib/observed/system.rb', line 13 def config=(config) @config = config end |
#now ⇒ Object
36 37 38 |
# File 'lib/observed/system.rb', line 36 def now Time.now end |
#run(observation_name = nil, data = nil, options = nil) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/observed/system.rb', line 21 def run(observation_name=nil, data=nil, =nil) = { tag: ( && [:tag]) || observation_name, time: now }.merge( || {}) params = [data, ] if observation_name fail "No configuration found for observation name '#{observation_name}'" if @context.config_builder.group(observation_name).empty? @context.config_builder.run_group(observation_name).send :now, *params else observers_to_run = @context.config_builder.observers fail "No configuration found for observation name '#{observation_name}'" if observers_to_run.empty? observers_to_run.each do |o| o.send :now, *params end end end |