BigW Consortium Gitlab

service.rb 1.19 KB
Newer Older
1 2 3 4
# == Schema Information
#
# Table name: services
#
Dmitriy Zaporozhets committed
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
Dmitriy Zaporozhets committed
10 11
#  created_at  :datetime
#  updated_at  :datetime
Dmitriy Zaporozhets committed
12 13
#  active      :boolean          default(FALSE), not null
#  project_url :string(255)
Dmitriy Zaporozhets committed
14 15
#  subdomain   :string(255)
#  room        :string(255)
Dmitriy Zaporozhets committed
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
Dmitriy Zaporozhets committed
23 24
  default_value_for :active, false

25
  attr_accessible :title, :token, :type, :active, :api_key
26 27 28 29 30

  belongs_to :project
  has_one :service_hook

  validates :project_id, presence: true
31 32 33 34

  def activated?
    active
  end
35

36 37 38 39
  def category
    :common
  end

40
  def title
41
    # implement inside child
42 43 44
  end

  def description
45
    # implement inside child
46 47
  end

48 49 50 51
  def help
    # implement inside child
  end

52
  def to_param
53
    # implement inside child
54 55 56
  end

  def fields
57
    # implement inside child
58 59
    []
  end
60 61 62 63

  def execute
    # implement inside child
  end
64 65 66 67

  def can_test?
    !project.empty_repo?
  end
68
end