diff options
author | Drew Blessing <drew.blessing@me.com> | 2014-09-07 19:54:18 -0500 |
---|---|---|
committer | Drew Blessing <drew.blessing@me.com> | 2014-09-10 09:56:39 -0500 |
commit | a0dbcd2365b9c90892ccd0c5dfb18c7c58de8704 (patch) | |
tree | 09b0e5a4027cb9187d9f46f4cd6ff75ac64ea1e6 /app/models/service.rb | |
parent | f42a1ded99920998a9b63b309adc227485428d2c (diff) | |
download | gitlab-ce-a0dbcd2365b9c90892ccd0c5dfb18c7c58de8704.tar.gz |
Serialize services properties
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 |