summaryrefslogtreecommitdiff
path: root/users/app/models/identity.rb
diff options
context:
space:
mode:
authorAzul <azul@leap.se>2013-07-19 12:21:40 +0200
committerAzul <azul@leap.se>2013-07-24 10:55:51 +0200
commitc0b88d9e8fe574d6164f48211db50f3b8a4c4d93 (patch)
tree20e42fd20547705acafb3c67efe4da381982a836 /users/app/models/identity.rb
parent51582a668b04d2c1322ad1babe8599ae8797cd3b (diff)
setter for keys for dirty tracking, more robust tests
Just altering identity.keys did not mark identities as changed. Also we now have a sane default for keys.
Diffstat (limited to 'users/app/models/identity.rb')
-rw-r--r--users/app/models/identity.rb11
1 files changed, 10 insertions, 1 deletions
diff --git a/users/app/models/identity.rb b/users/app/models/identity.rb
index b862590..73531ec 100644
--- a/users/app/models/identity.rb
+++ b/users/app/models/identity.rb
@@ -6,7 +6,7 @@ class Identity < CouchRest::Model::Base
property :address, LocalEmail
property :destination, Email
- property :keys, Hash
+ property :keys, HashWithIndifferentAccess
validate :unique_forward
validate :alias_available
@@ -27,6 +27,15 @@ class Identity < CouchRest::Model::Base
end
+ def keys
+ read_attribute('keys') || HashWithIndifferentAccess.new
+ end
+
+ def set_key(type, value)
+ return if keys[type] == value
+ write_attribute('keys', keys.merge(type => value))
+ end
+
protected
def unique_forward