-
-
Save sarahmei/812045 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module HasPersonProxy | |
module ClassMethods | |
def always_has_person | |
self.instance_eval do | |
include InstanceMethods | |
alias_method_chain :person, :proxy | |
end | |
end | |
end | |
module InstanceMethods | |
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 | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment