Class: Todo

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/todo.rb

Overview

Schema Information

Table name: todos

id          :integer          not null, primary key
user_id     :integer          not null
project_id  :integer          not null
target_id   :integer
target_type :string           not null
author_id   :integer
action      :integer          not null
state       :string           not null
created_at  :datetime
updated_at  :datetime
note_id     :integer
commit_id   :string

Constant Summary collapse

ASSIGNED =
1
MENTIONED =
2

Instance Method Summary collapse

Instance Method Details

#bodyObject


49
50
51
52
53
54
55
# File 'app/models/todo.rb', line 49

def body
  if note.present?
    note.note
  else
    target.title
  end
end

#for_commit?Boolean

Returns:

  • (Boolean)

57
58
59
# File 'app/models/todo.rb', line 57

def for_commit?
  target_type == "Commit"
end

#targetObject

override to return commits, which are not active record


62
63
64
65
66
67
68
# File 'app/models/todo.rb', line 62

def target
  if for_commit?
    project.commit(commit_id) rescue nil
  else
    super
  end
end

#target_referenceObject


70
71
72
73
74
75
76
# File 'app/models/todo.rb', line 70

def target_reference
  if for_commit?
    target.short_id
  else
    target.to_reference
  end
end