module Nark

Constants

VERSION

Attributes

emitter[W]

Public Class Methods

configure(&block) click to toggle source
# File lib/nark.rb, line 49
def configure(&block)
  block.call self
end
emitter() click to toggle source
# File lib/nark.rb, line 53
def emitter
  @emitter ||= InfluxDBEmitter.new(
    ENV['INFLUXDB_DATABASE'],
    username: ENV['INFLUXDB_USERNAME'],
    password: ENV['INFLUXDB_PASSWORD'],
    hosts: ENV['INFLUXDB_HOST'],
    port: ENV['INFLUXDB_PORT'],
    use_ssl: ENV['INFLUXDB_USE_SSL']
  )
end
included(klass) click to toggle source
# File lib/nark.rb, line 5
def self.included(klass)
  klass.extend ClassMethods
end

Public Instance Methods

collection_name(name = nil) click to toggle source
# File lib/nark.rb, line 21
def collection_name(name = nil)
  @collection_name = name if name
  @collection_name ||= self.class.collection_name

  @collection_name
end
emit(timestamp: nil) click to toggle source
# File lib/nark.rb, line 14
def emit(timestamp: nil)
  hash = serializable_hash.clone
  Nark.emitter.emit(collection_name, hash, timestamp)

  self
end
serializable_hash(value = nil) click to toggle source
# File lib/nark.rb, line 9
def serializable_hash(value = nil)
  @serializable_hash = value if value
  @serializable_hash
end