Class: Honeybadger::Api::Fault

Inherits:
Object
  • Object
show all
Defined in:
lib/honeybadger-api/fault.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ Fault

Public: Build a new instance of Fault

opts - A Hash of attributes to initialize a Fault

Returns a new Fault



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/honeybadger-api/fault.rb', line 14

def initialize(opts)
  @id = opts[:id]
  @project_id = opts[:project_id]
  @klass = opts[:klass]
  @action = opts[:action]
  @component = opts[:component]
  @message = opts[:message]
  @environment = opts[:environment]
  @ignored = opts[:ignored]
  @resolved = opts[:resolved]
  @notices_count = opts[:notices_count]
  @comments_count = opts[:comments_count]
  @last_notice_at = opts[:last_notice_at].nil? ? nil : DateTime.parse(opts[:last_notice_at])
  @created_at = opts[:created_at].nil? ? nil : DateTime.parse(opts[:created_at])
  @url = opts[:url]
  if opts[:assignee]
    @assignee = User.new(opts[:assignee][:name], opts[:assignee][:email])
  end
  @tags = opts[:tags]
  @deploy = Deploy.new(opts[:deploy]) unless opts[:deploy].nil?
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



5
6
7
# File 'lib/honeybadger-api/fault.rb', line 5

def action
  @action
end

#assigneeObject (readonly)

Returns the value of attribute assignee.



5
6
7
# File 'lib/honeybadger-api/fault.rb', line 5

def assignee
  @assignee
end

#comments_countObject (readonly)

Returns the value of attribute comments_count.



5
6
7
# File 'lib/honeybadger-api/fault.rb', line 5

def comments_count
  @comments_count
end

#componentObject (readonly)

Returns the value of attribute component.



5
6
7
# File 'lib/honeybadger-api/fault.rb', line 5

def component
  @component
end

#created_atObject (readonly)

Returns the value of attribute created_at.



5
6
7
# File 'lib/honeybadger-api/fault.rb', line 5

def created_at
  @created_at
end

#deployObject (readonly)

Returns the value of attribute deploy.



5
6
7
# File 'lib/honeybadger-api/fault.rb', line 5

def deploy
  @deploy
end

#environmentObject (readonly)

Returns the value of attribute environment.



5
6
7
# File 'lib/honeybadger-api/fault.rb', line 5

def environment
  @environment
end

#idObject (readonly)

Returns the value of attribute id.



5
6
7
# File 'lib/honeybadger-api/fault.rb', line 5

def id
  @id
end

#klassObject (readonly)

Returns the value of attribute klass.



5
6
7
# File 'lib/honeybadger-api/fault.rb', line 5

def klass
  @klass
end

#last_notice_atObject (readonly)

Returns the value of attribute last_notice_at.



5
6
7
# File 'lib/honeybadger-api/fault.rb', line 5

def last_notice_at
  @last_notice_at
end

#messageObject (readonly)

Returns the value of attribute message.



5
6
7
# File 'lib/honeybadger-api/fault.rb', line 5

def message
  @message
end

#notices_countObject (readonly)

Returns the value of attribute notices_count.



5
6
7
# File 'lib/honeybadger-api/fault.rb', line 5

def notices_count
  @notices_count
end

#project_idObject (readonly)

Returns the value of attribute project_id.



5
6
7
# File 'lib/honeybadger-api/fault.rb', line 5

def project_id
  @project_id
end

#tagsObject (readonly)

Returns the value of attribute tags.



5
6
7
# File 'lib/honeybadger-api/fault.rb', line 5

def tags
  @tags
end

#urlObject (readonly)

Returns the value of attribute url.



5
6
7
# File 'lib/honeybadger-api/fault.rb', line 5

def url
  @url
end

Class Method Details

.all(project_id) ⇒ Object

Public: Find all faults for a given project.



47
48
49
50
# File 'lib/honeybadger-api/fault.rb', line 47

def self.all(project_id)
  path  = "projects/#{project_id}/faults"
  Honeybadger::Api::Request.all(path, handler)
end

.find(project_id, fault_id) ⇒ Object

Public: Find a fault for a given project.



59
60
61
62
# File 'lib/honeybadger-api/fault.rb', line 59

def self.find(project_id, fault_id)
  path = "projects/#{project_id}/faults/#{fault_id}"
  Honeybadger::Api::Request.find(path, handler)
end

.handlerObject

Internal: The handler used to build objects from API responses.



65
66
67
# File 'lib/honeybadger-api/fault.rb', line 65

def self.handler
  Proc.new { |response| Fault.new(response) }
end

.paginate(project_id, filters = {}) ⇒ Object

Public: Paginate all faults for a given project.



53
54
55
56
# File 'lib/honeybadger-api/fault.rb', line 53

def self.paginate(project_id, filters = {})
  path  = "projects/#{project_id}/faults"
  Honeybadger::Api::Request.paginate(path, handler, filters)
end

Instance Method Details

#ignored?Boolean

Public: Whether tha fault has been marked as ignored.

Returns:

  • (Boolean)


37
38
39
# File 'lib/honeybadger-api/fault.rb', line 37

def ignored?
  @ignored == true
end

#resolved?Boolean

Public: Whether tha fault has been marked as resolved.

Returns:

  • (Boolean)


42
43
44
# File 'lib/honeybadger-api/fault.rb', line 42

def resolved?
  @resolved == true
end