Class: Rhoconnect::Handler::Changes::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/rhoconnect/handler/changes/runner.rb

Direct Known Subclasses

PassThroughRunner

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(operations, model, client, route_handler, params = {}) ⇒ Runner

Returns a new instance of Runner.

Raises:

  • (ArgumentError)


7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/rhoconnect/handler/changes/runner.rb', line 7

def initialize(operations,model,client,route_handler, params = {})
  raise ArgumentError.new(UNKNOWN_CLIENT) unless client
  raise ArgumentError.new(UNKNOWN_SOURCE) unless (model and model.source)
  raise ArgumentError.new('Invalid app for source') unless model.source.app

  @source,@client = model.source,client
  @model = model
  @client.last_sync = Time.now if @client
  @params = params
  @operations = operations
  @engine = Rhoconnect::Handler::Changes::Engine.new(@operations, @model, route_handler, @params)
end

Instance Attribute Details

#clientObject

Returns the value of attribute client.



5
6
7
# File 'lib/rhoconnect/handler/changes/runner.rb', line 5

def client
  @client
end

#engineObject

Returns the value of attribute engine.



5
6
7
# File 'lib/rhoconnect/handler/changes/runner.rb', line 5

def engine
  @engine
end

#modelObject

Returns the value of attribute model.



5
6
7
# File 'lib/rhoconnect/handler/changes/runner.rb', line 5

def model
  @model
end

#operationsObject

Returns the value of attribute operations.



5
6
7
# File 'lib/rhoconnect/handler/changes/runner.rb', line 5

def operations
  @operations
end

#paramsObject

Returns the value of attribute params.



5
6
7
# File 'lib/rhoconnect/handler/changes/runner.rb', line 5

def params
  @params
end

#sourceObject

Returns the value of attribute source.



5
6
7
# File 'lib/rhoconnect/handler/changes/runner.rb', line 5

def source
  @source
end

Instance Method Details

#runObject



20
21
22
23
24
25
26
27
28
# File 'lib/rhoconnect/handler/changes/runner.rb', line 20

def run
  _process_blobs(params)
  processed = 0
  operations.each do |op|
    key,value = op,params[op]
    processed += _receive_cud(key,value) if value
  end
  @engine.do_cud
end