summaryrefslogtreecommitdiff
path: root/users/app/models/pgp_key.rb
diff options
context:
space:
mode:
authorAzul <azul@leap.se>2013-11-26 11:22:47 +0100
committerAzul <azul@leap.se>2013-11-26 11:41:01 +0100
commit7de12c71ce7eb4eeb6e0795275434ed4a4120c25 (patch)
tree9916fcd11ccf289a9dfcf0f183f7655789464092 /users/app/models/pgp_key.rb
parent21cc6313320efa2992a58b7434468678ca6cf3b6 (diff)
ignore attempts to empty public_key, refactor
refactor: prepare validations of the uploaded pgp keys
Diffstat (limited to 'users/app/models/pgp_key.rb')
-rw-r--r--users/app/models/pgp_key.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/users/app/models/pgp_key.rb b/users/app/models/pgp_key.rb
new file mode 100644
index 0000000..fddec1e
--- /dev/null
+++ b/users/app/models/pgp_key.rb
@@ -0,0 +1,25 @@
+class PgpKey
+ include ActiveModel::Validations
+
+ # mostly for testing.
+ attr_accessor :key_block
+
+ def initialize(key_block = nil)
+ @key_block = key_block
+ end
+
+ def to_s
+ @key_block
+ end
+
+ def present?
+ @key_block.present?
+ end
+
+ # let's allow comparison with plain key_block strings.
+ def ==(other)
+ self.equal?(other) or
+ self.to_s == other
+ end
+
+end