Sha256: 4a26b2559f5667b9177dafca2f1f5f84d3f473374c72171110238764a763cc87

Contents?: true

Size: 640 Bytes

Versions: 13

Compression:

Stored size: 640 Bytes

Contents

module PhobosDBCheckpoint
  module EventHelper
    def configured_listener
      listener = Phobos
        .config
        .listeners
        .find { |l| l.group_id == self.group_id }

      raise(ListenerNotFoundError, self.group_id) unless listener

      listener
    end

    def configured_handler
      configured_listener
        .handler
        .constantize
    end

    def method_missing(m, *args, &block)
      rex = m.to_s.match /^fetch_(.+)/

      if rex
        handler = configured_handler.new
        return handler.send(rex[1], payload) if handler.respond_to?(rex[1])
      else
        super
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
phobos_db_checkpoint-3.3.0 lib/phobos_db_checkpoint/event_helper.rb
phobos_db_checkpoint-3.2.0 lib/phobos_db_checkpoint/event_helper.rb
phobos_db_checkpoint-3.1.0 lib/phobos_db_checkpoint/event_helper.rb
phobos_db_checkpoint-3.0.0 lib/phobos_db_checkpoint/event_helper.rb
phobos_db_checkpoint-2.4.0 lib/phobos_db_checkpoint/event_helper.rb
phobos_db_checkpoint-2.3.1 lib/phobos_db_checkpoint/event_helper.rb
phobos_db_checkpoint-2.3.0 lib/phobos_db_checkpoint/event_helper.rb
phobos_db_checkpoint-2.2.0 lib/phobos_db_checkpoint/event_helper.rb
phobos_db_checkpoint-2.1.0 lib/phobos_db_checkpoint/event_helper.rb
phobos_db_checkpoint-2.0.0 lib/phobos_db_checkpoint/event_helper.rb
phobos_db_checkpoint-2.0.0.rc1 lib/phobos_db_checkpoint/event_helper.rb
phobos_db_checkpoint-1.1.0 lib/phobos_db_checkpoint/event_helper.rb
phobos_db_checkpoint-1.0.0 lib/phobos_db_checkpoint/event_helper.rb