service.rb 1.1 KB
Newer Older
1 2 3 4
# == Schema Information
#
# Table name: services
#
D
Dmitriy Zaporozhets 已提交
5 6 7 8 9
#  id          :integer          not null, primary key
#  type        :string(255)
#  title       :string(255)
#  token       :string(255)
#  project_id  :integer          not null
D
Dmitriy Zaporozhets 已提交
10 11
#  created_at  :datetime
#  updated_at  :datetime
D
Dmitriy Zaporozhets 已提交
12 13
#  active      :boolean          default(FALSE), not null
#  project_url :string(255)
D
Dmitriy Zaporozhets 已提交
14 15
#  subdomain   :string(255)
#  room        :string(255)
D
Dmitriy Zaporozhets 已提交
16
#  recipients  :text
17
#  api_key     :string(255)
18 19
#

20 21
# To add new service you should build a class inherited from Service
# and implement a set of methods
22
class Service < ActiveRecord::Base
D
Dmitriy Zaporozhets 已提交
23 24
  default_value_for :active, false

25 26 27 28
  belongs_to :project
  has_one :service_hook

  validates :project_id, presence: true
29 30 31 32

  def activated?
    active
  end
33

34 35 36 37
  def category
    :common
  end

38
  def title
39
    # implement inside child
40 41 42
  end

  def description
43
    # implement inside child
44 45
  end

46 47 48 49
  def help
    # implement inside child
  end

50
  def to_param
51
    # implement inside child
52 53 54
  end

  def fields
55
    # implement inside child
56 57
    []
  end
58 59 60 61

  def execute
    # implement inside child
  end
62 63 64 65

  def can_test?
    !project.empty_repo?
  end
66
end