There are lots of places where it is legal to insert newlines in Ruby. For example your first snippet:
belongs_to(
:car,
-> {
includes(
:listable
)
.where(
listings:
{
listable_type:
Car
.to_s
}
)
},
foreign_key:
:listable_id
)
Your second snippet simply doesn't make sense. An object always knows its own class, there is never ever a reason for an object to check its own class. That is not just a code smell or an anti-pattern, that is a huge red flag that the author of that code has no understanding of object-orientation and inheritance.
The second snippet should be refactored using the Replace Conditional with Polymorphism Refactoring. You don't show enough code to see exactly how, but I would suggest something like this:
class Registration::Base
def initialize
raise ArgumentError, 'Can only initiate inherited Classes of Base, not Base Directly'
end
end