summaryrefslogtreecommitdiff
path: root/app/models/key.rb
diff options
context:
space:
mode:
authorNihad Abbasov <narkoz.2008@gmail.com>2012-09-26 23:20:36 -0700
committerNihad Abbasov <narkoz.2008@gmail.com>2012-09-27 02:05:53 -0700
commit841e4fbd08d2d642c127506001a76a973ea3d536 (patch)
tree56a894ecdf3978bc3032daa8fae294dad897018d /app/models/key.rb
parent2a4359a572c123d117988487f9bb29f4ae176ceb (diff)
downloadgitlab-ce-841e4fbd08d2d642c127506001a76a973ea3d536.tar.gz
cosmetical cleanup of models
Diffstat (limited to 'app/models/key.rb')
-rw-r--r--app/models/key.rb16
1 files changed, 6 insertions, 10 deletions
diff --git a/app/models/key.rb b/app/models/key.rb
index eadfcd85cd1..3ef21811c2d 100644
--- a/app/models/key.rb
+++ b/app/models/key.rb
@@ -6,14 +6,10 @@ class Key < ActiveRecord::Base
attr_accessible :key, :title
- validates :title,
- presence: true,
- length: { within: 0..255 }
-
- validates :key,
- presence: true,
- format: { :with => /ssh-.{3} / },
- length: { within: 0..5000 }
+ validates :title, presence: true, length: { within: 0..255 }
+ validates :key, presence: true,
+ length: { within: 0..5000 },
+ format: { :with => /ssh-.{3} / }
before_save :set_identifier
before_validation :strip_white_space
@@ -34,7 +30,7 @@ class Key < ActiveRecord::Base
def set_identifier
if is_deploy_key
- self.identifier = "deploy_" + Digest::MD5.hexdigest(key)
+ self.identifier = "deploy_#{Digest::MD5.hexdigest(key)}"
else
self.identifier = "#{user.identifier}_#{Time.now.to_i}"
end
@@ -57,6 +53,7 @@ class Key < ActiveRecord::Base
Key.where(identifier: identifier).count == 0
end
end
+
# == Schema Information
#
# Table name: keys
@@ -70,4 +67,3 @@ end
# identifier :string(255)
# project_id :integer
#
-