Module: Mutx::API::Results

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

Class Method Summary collapse

Class Method Details

.find_by_key(keyword) ⇒ Object



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

def self.find_by_key keyword
  response = self.structure
  response["results"] = Mutx::Results.find_for(keyword).map{|result| Mutx::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



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

def self.show(options = {})

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

end

.structureObject



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

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