summaryrefslogtreecommitdiff
path: root/app/serializers/phone_book_entry_serializer.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/serializers/phone_book_entry_serializer.rb')
-rw-r--r--app/serializers/phone_book_entry_serializer.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/app/serializers/phone_book_entry_serializer.rb b/app/serializers/phone_book_entry_serializer.rb
new file mode 100644
index 0000000..ac25832
--- /dev/null
+++ b/app/serializers/phone_book_entry_serializer.rb
@@ -0,0 +1,14 @@
+class PhoneBookEntrySerializer < ActiveModel::Serializer
+ embed :ids, :include => true
+
+ attributes :id, :first_name, :last_name, :organization, :search_result_display
+ has_many :phone_numbers
+
+ def search_result_display
+ result = "#{object.last_name}, #{object.first_name}".strip.gsub(/^, /,'').gsub(/,$/,'')
+ if result.blank?
+ result = "#{object.organization}"
+ end
+ return result
+ end
+end