Sha256: 26eaba71c311460c29e0d0dd0cecfad36fbc9cce2fca1323f28bd8abf114c694

Contents?: true

Size: 905 Bytes

Versions: 2

Compression:

Stored size: 905 Bytes

Contents

module Rhoconnect
  class SourceJob
    class << self
      attr_accessor :queue
    end

    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.do_sync
      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.do_cud
      end    
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rhoconnect-4.0.0.beta.10 lib/rhoconnect/jobs/source_job.rb
rhoconnect-4.0.0.beta.12 lib/rhoconnect/jobs/source_job.rb