Sha256: c33f80de592100950d604f1aaf1ea6bf1c23cb5526267475a79201221942cb15

Contents?: true

Size: 783 Bytes

Versions: 4

Compression:

Stored size: 783 Bytes

Contents

require 'time'
require 'chillout/event_data_builder'

module Chillout
  class ServerSide

    def initialize(event_data_builder, http_client)
      @http_client = http_client
      @event_data_builder = event_data_builder
    end

    def send_error(error)
      event_data = @event_data_builder.build_from_error(error, timestamp)
      send_event(event_data)
    end

    def send_event(data)
      @http_client.post('/events', data)
    end

    def send_creations(creations_container)
      event_data = @event_data_builder.build_from_creations_container(creations_container, timestamp)
      send_metric(event_data)
    end

    def send_metric(data)
      @http_client.post('/metrics', data)
    end

    private
      def timestamp
        Time.now.iso8601
      end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
chillout-0.2.3 lib/chillout/server_side.rb
chillout-0.2.2 lib/chillout/server_side.rb
chillout-0.2.1 lib/chillout/server_side.rb
chillout-0.2.0 lib/chillout/server_side.rb