Class: Infostrada::EndpointChecker

Inherits:
Object
  • Object
show all
Includes:
EM::Deferrable
Defined in:
lib/infostrada/endpoints_poller.rb

Overview

EndpointChecker is an helper class that will call CallRefresh.get_latest to check which updates were made since the last request. It will then call .succeed or .fail asynchronously.

Instance Method Summary collapse

Constructor Details

#initialize(endpoints_whitelist) ⇒ EndpointChecker



64
65
66
67
68
69
70
71
72
73
# File 'lib/infostrada/endpoints_poller.rb', line 64

def initialize(endpoints_whitelist)
  begin
    updated = Infostrada::CallRefresh.get_latest
    updated = updated.select { |endpoint| endpoints_whitelist.include?(endpoint.method) }

    self.succeed(updated)
  rescue => e
    self.fail(e.message)
  end
end