Sha256: 710100103ba265393d6776767a1f38ee872e8ab5d32e512dc771576b181b28eb

Contents?: true

Size: 980 Bytes

Versions: 3

Compression:

Stored size: 980 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
          table_event_data = @table_map_event.get_data

          row_event.database = table_event_data.get_database
          row_event.table    = 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.6.0-java lib/ecco/row_event_listener.rb
ecco-0.5.0-java lib/ecco/row_event_listener.rb
ecco-0.4.1-java lib/ecco/row_event_listener.rb