Class: Bicho::Query
Overview
Represents a bug search to the server and it can be configured with all bug attributes.
Instance Attribute Summary collapse
-
#query_map ⇒ Object
readonly
obtains the parameter that can be passed to the XMLRPC API.
Instance Method Summary collapse
-
#each {|Bicho::Bug| ... } ⇒ Object
Iterates through the result of the current query.
-
#initialize(conditions = {}) ⇒ Query
constructor
Create a query.
-
#L3 ⇒ Object
Shortcut, equivalent to :summary => “L3”.
-
#method_missing(method_name, *args) ⇒ Object
Query responds to all the bug search attributes.
-
#open ⇒ Object
Shortcut equivalent to status new, assigned, needinfo, reopened, confirmed, and in_progress.
- #respond_to_missing?(method_name, _include_private = false) ⇒ Boolean
Constructor Details
#initialize(conditions = {}) ⇒ Query
Create a query.
60 61 62 |
# File 'lib/bicho/query.rb', line 60 def initialize(conditions = {}) @query_map = conditions end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args) ⇒ Object
Query responds to all the bug search attributes.
67 68 69 70 71 72 73 74 75 |
# File 'lib/bicho/query.rb', line 67 def method_missing(method_name, *args) return super unless Bicho::SEARCH_FIELDS .map(&:first) .include?(method_name) args.each do |arg| append_query(method_name.to_s, arg) end self end |
Instance Attribute Details
#query_map ⇒ Object (readonly)
obtains the parameter that can be passed to the XMLRPC API
50 51 52 |
# File 'lib/bicho/query.rb', line 50 def query_map @query_map end |
Instance Method Details
#each {|Bicho::Bug| ... } ⇒ Object
Requires Bicho.client to be set
Iterates through the result of the current query.
42 43 44 45 46 |
# File 'lib/bicho/query.rb', line 42 def each ret = Bicho.client.search_bugs(self) return ret.each unless block_given? ret.each { |bug| yield bug } end |
#L3 ⇒ Object
Shortcut, equivalent to
:summary => "L3"
88 89 90 91 |
# File 'lib/bicho/query.rb', line 88 def L3 # rubocop:disable Naming/MethodName append_query('summary', 'L3') self end |
#open ⇒ Object
Shortcut equivalent to status new, assigned, needinfo, reopened, confirmed, and in_progress
82 83 84 |
# File 'lib/bicho/query.rb', line 82 def open status(:new).status(:assigned).status(:needinfo).status(:reopened).status(:confirmed).status(:in_progress) end |
#respond_to_missing?(method_name, _include_private = false) ⇒ Boolean
77 78 79 |
# File 'lib/bicho/query.rb', line 77 def respond_to_missing?(method_name, _include_private = false) Bicho::SEARCH_FIELDS.map(&:first).include?(method_name) || super end |