Class: Rawscsi::Search

Inherits:
Base
  • Object
show all
Defined in:
lib/rawscsi/search.rb

Instance Attribute Summary

Attributes inherited from Base

#config, #is_active_record, #model

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Rawscsi::Base

Instance Method Details

#search(arg, options = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/rawscsi/search.rb', line 5

def search(arg, options = {})
  if arg.is_a?(String)  
    query = Rawscsi::Query::Simple.new(arg).build
    raw = options[:raw]
  elsif arg.is_a?(Hash)
    query = Rawscsi::Query::Compound.new(arg).build
    raw = arg[:raw]
  else
    raise "Unknown argument type"
  end

  response = send_request_to_aws(query)
  results = results_container(response)

  if raw
    results
  else
    build_results(results)
  end
end