Class: RhoDevelopment::SubscriberPartialUpdateNotifyingTask

Inherits:
LiveUpdateTask show all
Defined in:
lib/build/development/live_update_task.rb

Overview

Notifies specified subscriber about a new partial update

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from LiveUpdateTask

descendants, #execute

Constructor Details

#initialize(aSubscriber, aFilename) ⇒ SubscriberPartialUpdateNotifyingTask

Initialize instance with instance of Subscriber

Parameters:

  • aSubscriber (Object)

    a Subscriber.



257
258
259
260
# File 'lib/build/development/live_update_task.rb', line 257

def initialize(aSubscriber, aFilename)
  @subscriber = aSubscriber
  @filename = aFilename
end

Class Method Details

.fromHash(aHash) ⇒ Object

Creates instance of class and parametrises it with values from passed argument

Parameters:

  • aHash (Hash)

    It needs to contain key named as ‘ip’ with subscriber IP.

Returns:

  • (Object)

    instance of SubscriberPartialUpdateNotifyingTask



249
250
251
252
253
# File 'lib/build/development/live_update_task.rb', line 249

def self.fromHash(aHash)
  subscriber = Configuration::subscriber_by_ip(aHash['ip'])
  filename = aHash['filename']
  self.new(subscriber, filename)
end

.taskNameString

Returns unique task name

Returns:

  • (String)

    Unique task name



242
243
244
# File 'lib/build/development/live_update_task.rb', line 242

def self.taskName
  'NotifySubscriberAboutPartialUpdate'
end

Instance Method Details

#actionObject

Notify the subscriber about partial update bundle



263
264
265
# File 'lib/build/development/live_update_task.rb', line 263

def action
  @subscriber.partial_notify(@filename)
end

#dispatchToUrl(anUri) ⇒ Object

Method serializes itself to a hash and sends post request with the hash to specified URI

Parameters:

  • anUri (URI)

    URI for post request



269
270
271
272
# File 'lib/build/development/live_update_task.rb', line 269

def dispatchToUrl(anUri)
  uri = URI.join(anUri, 'tasks/new')
  Net::HTTP.post_form(uri, {'taskName' => self.class.taskName, 'ip' => @subscriber.ip, 'filename' => @filename})
end