summaryrefslogtreecommitdiff
path: root/app/serializers/switchboard_entry_serializer.rb
diff options
context:
space:
mode:
authorStefan Wintermeyer <stefan.wintermeyer@amooma.de>2013-04-03 22:10:32 +0200
committerStefan Wintermeyer <stefan.wintermeyer@amooma.de>2013-04-03 22:10:32 +0200
commit4ebbcf3b5576cc342086e2f54950a119a49f2bf9 (patch)
treee216a9634c31047e8908a882aed9ff2545ed99e6 /app/serializers/switchboard_entry_serializer.rb
parentedf06bf6f7d4f20d5a9145a5bbf8db409fe6ab1b (diff)
parentcea2cc3c1cc1e48fc4600c698d52dfda2bde4505 (diff)
Merge branch 'emberjs' into develop
Diffstat (limited to 'app/serializers/switchboard_entry_serializer.rb')
-rw-r--r--app/serializers/switchboard_entry_serializer.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/app/serializers/switchboard_entry_serializer.rb b/app/serializers/switchboard_entry_serializer.rb
new file mode 100644
index 0000000..1b6c761
--- /dev/null
+++ b/app/serializers/switchboard_entry_serializer.rb
@@ -0,0 +1,14 @@
+class SwitchboardEntrySerializer < ActiveModel::Serializer
+ attributes :id, :name, :path_to_user, :avatar_src, :callstate
+
+ has_one :sip_account, embed: :ids
+ has_one :switchboard, embed: :ids
+
+ def path_to_user
+ if object.sip_account && object.sip_account.sip_accountable_type == 'User'
+ "/tenants/#{object.sip_account.sip_accountable.current_tenant.id}/users/#{object.sip_account.sip_accountable.id}"
+ else
+ nil
+ end
+ end
+end