module LogStasher::Device

Public Class Methods

factory(config) click to toggle source
# File lib/logstasher/device.rb, line 3
def self.factory(config)
  config = stringify_keys(config)
  type   = config.delete('type') or fail ArgumentError, 'No "type" given'

  case type
  when 'redis', :redis then
    require 'logstasher/device/redis'
    ::LogStasher::Device::Redis.new(config)
  when "syslog", :syslog then
    require 'logstasher/device/syslog'
    ::LogStasher::Device::Syslog.new(config)
  else
    fail ArgumentError, "Unknown type: #{type}"
  end
end
stringify_keys(hash) click to toggle source
# File lib/logstasher/device.rb, line 19
def stringify_keys(hash)
  hash.inject({}) do |stringified_hash, (key, value)|
    stringified_hash[key.to_s] = value
    stringified_hash
  end
end

Private Instance Methods

stringify_keys(hash) click to toggle source
# File lib/logstasher/device.rb, line 19
def stringify_keys(hash)
  hash.inject({}) do |stringified_hash, (key, value)|
    stringified_hash[key.to_s] = value
    stringified_hash
  end
end