diff options
author | Azul <azul@leap.se> | 2013-11-26 11:22:47 +0100 |
---|---|---|
committer | elijah <elijah@riseup.net> | 2013-12-06 15:52:11 -0800 |
commit | e64e746759bb241536612c949361442f269ef2f0 (patch) | |
tree | 7d05a83ebfa23df3dbb1b9ceeecbef057c6c1eb2 /users/app/models/pgp_key.rb | |
parent | 015ad90c98c55a078fdfe723d470ad732e807737 (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.rb | 25 |
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 |