class Protor
Constants
- DEFAULT_CONFIG
- VERSION
Attributes
config[R]
registry[R]
Public Class Methods
new() { |config| ... }
click to toggle source
Calls superclass method
# File lib/protor.rb, line 22 def initialize(&block) super(&block) @config = DEFAULT_CONFIG.dup @registry = Registry.new yield(config) if block_given? end
Public Instance Methods
publish()
click to toggle source
# File lib/protor.rb, line 30 def publish safely do client.publish(registry) registry.reset end logger.debug("publish") if logger end
Private Instance Methods
client()
click to toggle source
# File lib/protor.rb, line 54 def client @client ||= case config[:client] when :udp; UDPClient.new(config[:host], config[:port], formatter) when :logger; LoggerClient.new(logger, formatter) end end
formatter()
click to toggle source
# File lib/protor.rb, line 62 def formatter @formatter ||= case config[:formatter] when :udp; UDPFormatter.new(config[:packet_size]) end end
logger()
click to toggle source
# File lib/protor.rb, line 69 def logger config[:logger] end
safely(&block)
click to toggle source
# File lib/protor.rb, line 47 def safely(&block) synchronize(&block) rescue StandardError => err logger.error(err) if logger raise err unless silent end
silent()
click to toggle source
# File lib/protor.rb, line 73 def silent config[:silent] end