Class: Rhoconnect::SourceJob

Inherits:
Object
  • Object
show all
Defined in:
lib/rhoconnect/jobs/source_job.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.queueObject

Returns the value of attribute queue.



4
5
6
# File 'lib/rhoconnect/jobs/source_job.rb', line 4

def queue
  @queue
end

Class Method Details

.perform(job_type, source_id, app_id, user_id, params) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/rhoconnect/jobs/source_job.rb', line 7

def self.perform(job_type,source_id,app_id,user_id,params)
  source = Source.load(source_id,{:app_id => app_id,:user_id => user_id})
  params ||= {}

  case job_type.to_sym
  when :query 
    handler_sync = lambda { @model.query(params[:query])}
    @model = Rhoconnect::Model::Base.create(source)
    source_sync = Rhoconnect::Handler::Query::Engine.new(@model, handler_sync, params)
    source_sync.run_query
  when :cud
    handler_cud = lambda { @model.send params[:operation].to_sym, params["#{params[:operation]}_object".to_sym] }
    @model = Rhoconnect::Model::Base.create(source)
    source_cud = Rhoconnect::Handler::Changes::Engine.new(['create', 'update', 'delete'], @model, handler_cud, params)
    source_cud.run_cud
  end    
end