Module: Kaya::API::Results

Defined in:
lib/kaya/API/results.rb

Class Method Summary collapse

Class Method Details

.find_by_key(keyword) ⇒ Object



15
16
17
18
19
20
# File 'lib/kaya/API/results.rb', line 15

def self.find_by_key keyword
  response = self.structure
  response["results"] = Kaya::Results.find_for(keyword).map{|result| Kaya::API::Result.info(result["_id"])}
  response["message"] = "No results found" if (response["size"] = response["results"].size).zero?
  response
end

.show(options = {}) ⇒ Object

Parameters:

  • options (Hash) (defaults to: {})

    :msg



6
7
8
9
10
11
12
13
# File 'lib/kaya/API/results.rb', line 6

def self.show(options = {})

  response = self.structure
  response["results"] = Kaya::Results.all_results.map{|result| Kaya::API::Result.info(result["_id"])}
  response["message"] = "No results found" if (response["size"] = response["results"].size).zero?
  response

end

.structureObject



22
23
24
25
26
27
28
# File 'lib/kaya/API/results.rb', line 22

def self.structure
  response = {
    "project_name" => Dir.pwd.split("/").last,
    "results" => []
  }
  response
end