diff options
Diffstat (limited to 'users/app/models/identity.rb')
-rw-r--r-- | users/app/models/identity.rb | 11 |
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 |