summaryrefslogtreecommitdiff
path: root/users/app/models/account.rb
diff options
context:
space:
mode:
authorAzul <azul@leap.se>2013-11-15 11:53:21 +0100
committerAzul <azul@leap.se>2013-11-15 11:53:21 +0100
commit8b49ee15466b728213ec7f8bd4c8462876625acf (patch)
treec301a8033650a1067c9caf012669d1a47d6f2a0c /users/app/models/account.rb
parent7e93258f552d6fd1114626561e6393aa483228fe (diff)
parent7a107e0d38271e7103d3494e06d52f3434022f22 (diff)
Merge branch 'develop'
Diffstat (limited to 'users/app/models/account.rb')
-rw-r--r--users/app/models/account.rb14
1 files changed, 10 insertions, 4 deletions
diff --git a/users/app/models/account.rb b/users/app/models/account.rb
index 5368a1b..5c943bb 100644
--- a/users/app/models/account.rb
+++ b/users/app/models/account.rb
@@ -1,5 +1,10 @@
#
-# A Composition of a User record and it's identity records.
+# The Account model takes care of the livecycle of a user.
+# It composes a User record and it's identity records.
+# It also allows for other engines to hook into the livecycle by
+# monkeypatching the create, update and destroy methods.
+# There's an ActiveSupport load_hook at the end of this file to
+# make this more easy.
#
class Account
@@ -29,9 +34,7 @@ class Account
def destroy
return unless @user
- Identity.by_user_id.key(@user.id).each do |identity|
- identity.destroy
- end
+ Identity.disable_all_for(@user)
@user.destroy
end
@@ -54,4 +57,7 @@ class Account
@new_identity.try(:save) && @old_identity.try(:save)
end
+ # You can hook into the account lifecycle from different engines using
+ # ActiveSupport.on_load(:account) do ...
+ ActiveSupport.run_load_hooks(:account, self)
end