mirror of
https://github.com/awesome-print/awesome_print
synced 2023-03-27 23:22:34 -04:00
Use ancestors instead of manually walking the superclass chain.
This commit is contained in:
parent
d60f1d8719
commit
1e28a85396
1 changed files with 1 additions and 8 deletions
|
@ -18,7 +18,7 @@ module AwesomePrintActiveRecord
|
|||
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
|
||||
|
@ -48,13 +48,6 @@ module AwesomePrintActiveRecord
|
|||
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)
|
||||
|
|
Loading…
Reference in a new issue