Class: Bicho::Query

Inherits:
Object
  • Object
show all
Defined in:
lib/bicho/query.rb

Overview

Represents a bug search to the server and it can be configured with all bug attributes.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(conditions = {}) ⇒ Query

Create a query.

Examples:

query from a hash containing the attributes:

q = Query.new({:summary => "substring", :assigned_to => "foo@bar.com"})

using chainable methods:

q = Query.new.assigned_to("foo@bar.com@).summary("some text")


58
59
60
# File 'lib/bicho/query.rb', line 58

def initialize(conditions={})
  @query_map = conditions
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object

Query responds to all the bug search attributes.

See Also:

  • Allowed attributes}


65
66
67
68
69
70
# File 'lib/bicho/query.rb', line 65

def method_missing(name, *args)
  args.each do |arg|
    append_query(name.to_s, arg)
  end
  self
end

Instance Attribute Details

#query_mapObject (readonly)

obtains the parameter that can be passed to the XMLRPC API



48
49
50
# File 'lib/bicho/query.rb', line 48

def query_map
  @query_map
end

Instance Method Details

#each {|Bicho::Bug| ... } ⇒ Object

Note:

Requires Bicho.client to be set

Iterates through the result of the current query.

Yields:



40
41
42
43
44
# File 'lib/bicho/query.rb', line 40

def each
 ret = Bicho.client.search_bugs(self)
 return ret.each if not block_given?
 ret.each { |bug| yield bug }
end

#L3Object

Shortcut, equivalent to

:summary => "L3"


79
80
81
82
# File 'lib/bicho/query.rb', line 79

def L3
  append_query("summary", "L3")
  self
end

#openObject

Shortcut equivalent to status new, assigned, needinfo and reopened



73
74
75
# File 'lib/bicho/query.rb', line 73

def open
  status(:new).status(:assigned).status(:needinfo).status(:reopened)
end