class Observed::System
Public Class Methods
new(args={})
click to toggle source
# 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
Public Instance Methods
config()
click to toggle source
# File lib/observed/system.rb, line 17 def config @config end
config=(config)
click to toggle source
# File lib/observed/system.rb, line 13 def config=(config) @config = config end
now()
click to toggle source
# File lib/observed/system.rb, line 36 def now Time.now end
run(observation_name=nil, data=nil, options=nil)
click to toggle source
# File lib/observed/system.rb, line 21 def run(observation_name=nil, data=nil, options=nil) options = { tag: (options && options[:tag]) || observation_name, time: now }.merge(options || {}) params = [data, options] 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