class Proxy

Public Class Methods

new(*args) click to toggle source
Calls superclass method
# File lib/twing_proxy/proxy.rb, line 5
def initialize(*args)
  super
  @endpoints = setting.endpoints
end

Public Instance Methods

on_message(object) click to toggle source
# File lib/twing_proxy/proxy.rb, line 10
def on_message(object)
  case object
  when Twitter::Tweet
    logger.debug("Tweet #{object.id}")
    execute(object)
  end
end

Private Instance Methods

execute(object) click to toggle source
# File lib/twing_proxy/proxy.rb, line 20
def execute(object)
  @endpoints.each do |endpoint|
    Thread.new do
      begin
        RestClient.post(
          endpoint,
          object.to_h.to_json,
          content_type: :json,
          accept: :json
        )
      rescue => e
        logger.error("#{e.class} #{e.message}")
      end
    end
  end
end