Skip to content

Instantly share code, notes, and snippets.

@mileszs
Created March 4, 2014 13:31
Show Gist options
  • Select an option

  • Save mileszs/9346572 to your computer and use it in GitHub Desktop.

Select an option

Save mileszs/9346572 to your computer and use it in GitHub Desktop.
class From
attr_accessor :original
def initialize(object)
self.original = object
end
def id
"#{original.class}-#{original.id}"
end
def name
self.send("#{original.class.to_s.downcase}_name")
end
def conversations
@conversations ||= ConversationDecorator.decorate_collection(original.mailbox.conversations.order(updated_at: :desc))
end
private
def role_name
if original.resource_type.present? && original.resource_type == 'Clinic'
"#{original.name} at clinic #{original.resource.name}"
elsif original.resource_type.present? && original.resource_type == 'Employer'
"#{original.name} at #{original.resource.name}"
else
original.name
end
end
def user_name
original.name
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment