Skip to content

Commit

Permalink
Use ancestors instead of manually walking the superclass chain.
Browse files Browse the repository at this point in the history
  • Loading branch information
tobias committed Apr 22, 2010
1 parent d60f1d8 commit 1e28a85
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions lib/ap/mixin/active_record.rb
Expand Up @@ -18,7 +18,7 @@ def printable_with_active_record(object)
if object.is_a?(ActiveRecord::Base)
printable = :active_record_instance
end
elsif printable == :class and class_inherits_from(object, ActiveRecord::Base)
elsif printable == :class and object.ancestors.include?(ActiveRecord::Base)
printable = :active_record_class
end
printable
Expand Down Expand Up @@ -48,13 +48,6 @@ def awesome_active_record_class(object)
end
end

private
def class_inherits_from(klass, parent_class)
while klass do
return true if klass == parent_class
klass = klass.superclass
end
end
end

AwesomePrint.send(:include, AwesomePrintActiveRecord)

0 comments on commit 1e28a85

Please sign in to comment.