Skip to content

Instantly share code, notes, and snippets.

Created February 5, 2011 00:02
Show Gist options
  • Save anonymous/812044 to your computer and use it in GitHub Desktop.
Save anonymous/812044 to your computer and use it in GitHub Desktop.
module HasPersonProxy
module ClassMethods
def person_with_proxy
self.person_without_proxy || DeletedPersonProxy.new(self)
end
end
class DeletedPersonProxy
def initialize(object=nil)
unless object.nil?
Rails.logger.info("event=person_proxy object=#{object.class} object_id=#{object.id} deleted_person_id=#{object.person_id} ")
end
@empty = ''
@h = '#'
end
#def id
# @h
#end
def name
'Diaspora User'
end
def owner_id
nil
end
def method_missing(*args)
@empty
end
end
def self.included(base)
base.class_eval do
base.extend ClassMethods
base.class_eval do
alias_method_chain :person, :proxy
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment