Sha256: e17c9987c81afa10de22b40cb643d2199c01f1fd7d7bb12fe0fa22cddf6f7dcb

Contents?: true

Size: 962 Bytes

Versions: 3

Compression:

Stored size: 962 Bytes

Contents

require "ecco/event_listener"
require "ecco/row_event"

module Ecco
  class RowEventListener < EventListener
    ROW_EVENTS = [
      EventType::WRITE_ROWS,
      EventType::UPDATE_ROWS,
      EventType::DELETE_ROWS,
    ]

    def table_event
      EventType::TABLE_MAP
    end

    def accepted_events
      ROW_EVENTS
    end

    def on_event(event)
      data = event.get_data
      type = event.get_header.get_event_type

      case type
      when table_event
        @table_map_event = event
      when *accepted_events
        row_event          = Ecco::RowEvent.new
        row_event.type     = type.to_s
        row_event.table_id = data.get_table_id
        row_event.rows     = data.rows

        if @table_map_event
          event_data = @table_map_event.get_data

          row_event.database = event_data.get_database
          row_event.table    = event_data.get_table
        end

        @callback.call(row_event)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ecco-0.4.0-java lib/ecco/row_event_listener.rb
ecco-0.3.1-java lib/ecco/row_event_listener.rb
ecco-0.3.0-java lib/ecco/row_event_listener.rb