Sha256: 23cdc5fcc2fa08402e9cf4e78aace6a8b849ff593794d6e9df26f1025f6dace0

Contents?: true

Size: 846 Bytes

Versions: 10

Compression:

Stored size: 846 Bytes

Contents

class G5Updatable::ClientFeedProcessor
  attr_reader :client_uid

  def initialize(client_uid=nil)
    @client_uid = client_uid || ENV["CLIENT_UID"]
    raise "A client_uid must be either passed in or configured!" if @client_uid.blank?
  end

  class << self
    def load_all_clients(clients_url)
      client_uids = G5FoundationClient::Client.all_client_uids clients_url
      client_uids.collect { |client_uid| new(client_uid).work }
    end
  end

  def work
    client = update_client
    update_locations

    client
  end

  private

  def update_locations
    G5Updatable::LocationsUpdater.new(foundation_client.locations).update
  end

  def update_client
    G5Updatable::ClientUpdater.new(foundation_client).update
  end

  def foundation_client
    @foundation_client ||= G5FoundationClient::Client.find_by_uid(@client_uid)
  end

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
g5_updatable-0.5.1 lib/g5_updatable/client_feed_processor.rb
g5_updatable-0.5.0 lib/g5_updatable/client_feed_processor.rb
g5_updatable-0.4.3 lib/g5_updatable/client_feed_processor.rb
g5_updatable-0.4.2 lib/g5_updatable/client_feed_processor.rb
g5_updatable-0.4.1 lib/g5_updatable/client_feed_processor.rb
g5_updatable-0.4.0 lib/g5_updatable/client_feed_processor.rb
g5_updatable-0.3.5 lib/g5_updatable/client_feed_processor.rb
g5_updatable-0.3.4 lib/g5_updatable/client_feed_processor.rb
g5_updatable-0.3.3 lib/g5_updatable/client_feed_processor.rb
g5_updatable-0.3.2 lib/g5_updatable/client_feed_processor.rb