Class: SearchKit::Polling::Process

Inherits:
Object
  • Object
show all
Defined in:
lib/search_kit/polling/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.



13
14
15
16
17
# File 'lib/search_kit/polling/process.rb', line 13

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

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block.



11
12
13
# File 'lib/search_kit/polling/process.rb', line 11

def block
  @block
end

#channelObject (readonly)

Returns the value of attribute channel.



11
12
13
# File 'lib/search_kit/polling/process.rb', line 11

def channel
  @channel
end

#clientObject (readonly)

Returns the value of attribute client.



11
12
13
# File 'lib/search_kit/polling/process.rb', line 11

def client
  @client
end

Class Method Details

.perform(channel, &block) ⇒ Object



7
8
9
# File 'lib/search_kit/polling/process.rb', line 7

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

Instance Method Details

#performObject



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

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