Class: Bicho::Bug

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, data) ⇒ Bug

Normally you will not use this constructor as bugs will be constructed by a query result



55
56
57
58
# File 'lib/bicho/bug.rb', line 55

def initialize(client, data)
  @client = client
  @data = data
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object



60
61
62
# File 'lib/bicho/bug.rb', line 60

def method_missing(name, *args)
  @data[name.to_s]
end

Class Method Details

.where(conditions = {}) ⇒ Array

ActiveRecord like interface

Requires Bicho.client to be set

alias

Examples:

Searching for bugs

Bug.where(:summary => "crash").each do |bug|
  #...do something with bug
end

See Also:



46
47
48
# File 'lib/bicho/bug.rb', line 46

def self.where(conditions={})
  return Query.new(conditions)
end

Instance Method Details

#idObject



64
65
66
67
68
# File 'lib/bicho/bug.rb', line 64

def id
  # we define id to not get the deprecated
  # warning of object_id
  @data['id']
end

#to_sObject



70
71
72
# File 'lib/bicho/bug.rb', line 70

def to_s
  "##{id} - #{summary} (#{url})"
end

#urlObject

URL where the bug can be viewed Example: bugs.foo.com/2345



76
77
78
# File 'lib/bicho/bug.rb', line 76

def url
  "#{@client.url}/#{id}"
end