Class: Rhoconnect::Handler::Search::Runner

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

Direct Known Subclasses

PassThroughRunner

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Runner.

Raises:

  • (ArgumentError)


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

def initialize(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,@p_size = model.source,client,params[:p_size] ? params[:p_size].to_i : 500
  @model = model
  @client.last_sync = Time.now if @client
  @params = params
  @engine = Rhoconnect::Handler::Search::Engine.new(@model, @client, route_handler, @params)
end

Instance Attribute Details

#clientObject

Returns the value of attribute client.



6
7
8
# File 'lib/rhoconnect/handler/search/runner.rb', line 6

def client
  @client
end

#engineObject

Returns the value of attribute engine.



6
7
8
# File 'lib/rhoconnect/handler/search/runner.rb', line 6

def engine
  @engine
end

#modelObject

Returns the value of attribute model.



6
7
8
# File 'lib/rhoconnect/handler/search/runner.rb', line 6

def model
  @model
end

#p_sizeObject

Returns the value of attribute p_size.



6
7
8
# File 'lib/rhoconnect/handler/search/runner.rb', line 6

def p_size
  @p_size
end

#paramsObject

Returns the value of attribute params.



6
7
8
# File 'lib/rhoconnect/handler/search/runner.rb', line 6

def params
  @params
end

#sourceObject

Returns the value of attribute source.



6
7
8
# File 'lib/rhoconnect/handler/search/runner.rb', line 6

def source
  @source
end

Instance Method Details

#runObject



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

def run
  if params
    return _resend_search_result if params[:token] and params[:resend]
    if params[:token] and !_ack_search(params[:token]) 
      formatted_result = _format_search_result
      _delete_search
      return formatted_result
    end
  end
  _do_search
end