P
Perry Smith
ActiveRecord does this "trick". For a normal object, this dump
routine:
def dump(name, obj)
puts "#{name}'s ancestors: #{obj.class.ancestors.inspect}"
puts "#{name}'s funky ancestors: #{(class << obj; self;
end).ancestors.inspect}"
end
produces the same list for ancestors and funky ancestors. For an
ActiveRecord Association, you get something like this:
temp's ancestors: [ Cached::Queue <snip...>
ActiveRecord::Locking:essimistic, ActiveRecord::Locking::Optimistic,
ActiveRecord::Validations, Object, Socket::Constants,
InstanceExecMethods, Base64:eprecated, Base64, Kernel]
temp's funky ancestors:
[ActiveRecord::Associations::BelongsToAssociation,
ActiveRecord::Associations::AssociationProxy, Object, Socket::Constants,
InstanceExecMethods, Base64:eprecated, Base64, Kernel]
Can someone tell me how this is done or point me to the code in active
record?
Thank you very much,
Perry
routine:
def dump(name, obj)
puts "#{name}'s ancestors: #{obj.class.ancestors.inspect}"
puts "#{name}'s funky ancestors: #{(class << obj; self;
end).ancestors.inspect}"
end
produces the same list for ancestors and funky ancestors. For an
ActiveRecord Association, you get something like this:
temp's ancestors: [ Cached::Queue <snip...>
ActiveRecord::Locking:essimistic, ActiveRecord::Locking::Optimistic,
ActiveRecord::Validations, Object, Socket::Constants,
InstanceExecMethods, Base64:eprecated, Base64, Kernel]
temp's funky ancestors:
[ActiveRecord::Associations::BelongsToAssociation,
ActiveRecord::Associations::AssociationProxy, Object, Socket::Constants,
InstanceExecMethods, Base64:eprecated, Base64, Kernel]
Can someone tell me how this is done or point me to the code in active
record?
Thank you very much,
Perry