Class: Bicho::Bug

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

Class Method Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Bug) initialize(client, data)

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

- (Object) method_missing(name, *args)



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

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

Class Method Details

+ (Array) where(conditions = {})

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

- (Object) [](name, subname = nil)



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

def [] name, subname = nil
  v = @data[name.to_s]
  v = v[subname.to_s] if subname # for 'internals' properties
  v
end

- (Object) id



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

- (Object) to_s



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

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

- (Object) url

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



82
83
84
# File 'lib/bicho/bug.rb', line 82

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