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

19 20
# To add new service you should build a class inherited from Service
# and implement a set of methods
21
class Service < ActiveRecord::Base
22
  attr_accessible :title, :token, :type, :active, :api_key
23 24 25 26 27

  belongs_to :project
  has_one :service_hook

  validates :project_id, presence: true
28 29 30 31

  def activated?
    active
  end
32 33

  def title
34
    # implement inside child
35 36 37
  end

  def description
38
    # implement inside child
39 40 41
  end

  def to_param
42
    # implement inside child
43 44 45
  end

  def fields
46
    # implement inside child
47 48
    []
  end
49 50 51 52

  def execute
    # implement inside child
  end
53 54 55 56

  def can_test?
    !project.empty_repo?
  end
57
end