Permalink
Browse files

keep AssociationProxy#to_a to avoid warning in Array(post.author), an…

…d delegate it to @target in association collections

[#4165 state:committed]

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
  • Loading branch information...
1 parent 611744e commit fe43bbd8c71fabb4b612808c42461b2ba9655318 @fxn fxn committed with jeremy Mar 12, 2010
@@ -101,6 +101,7 @@ def to_ary
Array(@target)
end
end
+ alias_method :to_a, :to_ary
def reset
reset_target!
@@ -49,7 +49,7 @@ class AssociationProxy #:nodoc:
alias_method :proxy_respond_to?, :respond_to?
alias_method :proxy_extend, :extend
delegate :to_param, :to => :proxy_target
- instance_methods.each { |m| undef_method m unless m =~ /(^__|^nil\?$|^send$|proxy_|^object_id$)/ }
+ instance_methods.each { |m| undef_method m unless m =~ /^(?:nil\?|send|object_id|to_a)$|^__|proxy_/ }
def initialize(owner, reflection)
@owner, @reflection = owner, reflection

0 comments on commit fe43bbd

Please sign in to comment.