Class: SearchKit::Events::Poll::Process

Inherits:
Object
  • Object
show all
Defined in:
lib/search_kit/events/poll/process.rb

Overview

The logic of interacting with the event service to retrieve and process events is contained here.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(channel, &block) ⇒ Process

Returns a new instance of Process.



14
15
16
17
18
# File 'lib/search_kit/events/poll/process.rb', line 14

def initialize(channel, &block)
  @block   = block
  @channel = channel
  @client  = SearchKit::Events.new
end

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block.



12
13
14
# File 'lib/search_kit/events/poll/process.rb', line 12

def block
  @block
end

#channelObject (readonly)

Returns the value of attribute channel.



12
13
14
# File 'lib/search_kit/events/poll/process.rb', line 12

def channel
  @channel
end

#clientObject (readonly)

Returns the value of attribute client.



12
13
14
# File 'lib/search_kit/events/poll/process.rb', line 12

def client
  @client
end

Class Method Details

.perform(channel, &block) ⇒ Object



8
9
10
# File 'lib/search_kit/events/poll/process.rb', line 8

def self.perform(channel, &block)
  new(channel, &block).perform
end

Instance Method Details

#performObject



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/search_kit/events/poll/process.rb', line 20

def perform
  events.each do |event|
    begin
      block.call(event)
    rescue
      raise
    else
      client.complete(event.id)
    end
  end
end