Created
March 30, 2010 19:20
-
-
Save adamhunter/349474 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
# mongo | |
def proxy_class | |
return @proxy_class if defined?(@proxy_class) | |
@proxy_class = | |
if many? | |
if klass.embeddable? | |
polymorphic? ? ManyEmbeddedPolymorphicProxy : ManyEmbeddedProxy | |
else | |
if polymorphic? | |
ManyPolymorphicProxy | |
elsif as? | |
ManyDocumentsAsProxy | |
elsif in_array? | |
InArrayProxy | |
else | |
ManyDocumentsProxy | |
end | |
end | |
elsif one? | |
OneProxy | |
else | |
polymorphic? ? BelongsToPolymorphicProxy : BelongsToProxy | |
end | |
end | |
# what i am thinking | |
def proxy_class | |
return @proxy_class if defined?(@proxy_class) | |
proxy_class_name.constantize | |
end | |
def proxy_class_name | |
@using ||= klass.embeddable? ? :embedded : :link | |
(many? ? 'Many' : 'One') + @using.to_s.classify + ('Polymorphic' if polymorphic?).to_s + 'Proxy' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment