diff options
Diffstat (limited to 'app/models/service.rb')
-rw-r--r-- | app/models/service.rb | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/app/models/service.rb b/app/models/service.rb index 0dc6d514b46..edfb31cbe08 100644 --- a/app/models/service.rb +++ b/app/models/service.rb @@ -5,22 +5,19 @@ # id :integer not null, primary key # type :string(255) # title :string(255) -# token :string(255) # project_id :integer not null # created_at :datetime # updated_at :datetime # active :boolean default(FALSE), not null -# project_url :string(255) -# subdomain :string(255) -# room :string(255) -# recipients :text -# api_key :string(255) -# +# properties :text # To add new service you should build a class inherited from Service # and implement a set of methods class Service < ActiveRecord::Base + serialize :properties, JSON + default_value_for :active, false + default_value_for :properties, {} belongs_to :project has_one :service_hook @@ -63,4 +60,20 @@ class Service < ActiveRecord::Base def can_test? !project.empty_repo? end + + # Provide convenient accessor methods + # for each serialized property. + def self.prop_accessor(*args) + args.each do |arg| + class_eval %{ + def #{arg} + properties['#{arg}'] + end + + def #{arg}=(value) + self.properties['#{arg}'] = value + end + } + end + end end |