Class: SearchKit::Events::CLI::Complete

Inherits:
Object
  • Object
show all
Includes:
Messaging
Defined in:
lib/search_kit/events/cli/complete.rb

Overview

An extraction of the CLI command, “complete”.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Messaging

#info, #warning

Constructor Details

#initialize(client, id) ⇒ Complete



13
14
15
16
# File 'lib/search_kit/events/cli/complete.rb', line 13

def initialize(client, id)
  @client = client
  @id     = id
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



11
12
13
# File 'lib/search_kit/events/cli/complete.rb', line 11

def client
  @client
end

#idObject (readonly)

Returns the value of attribute id.



11
12
13
# File 'lib/search_kit/events/cli/complete.rb', line 11

def id
  @id
end

Instance Method Details

#performObject



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/search_kit/events/cli/complete.rb', line 18

def perform
  client.complete(id)

  info "Event #{id} completed"
rescue Errors::EventNotFound
  warning "No event found for #{id}"
rescue Faraday::ConnectionFailed
  warning "Remote events service not found"
rescue JSON::ParserError => error
  warning "Response unreadable: #{error}"
  error.backtrace.each(&method(:warning))
end