It works because when `DateTime` is defined, `defined?(DateTime) && DateTime` evaluates to `DateTime`, and so in that case it's the same as `when DateTime`.

However, I think this will have a bug when `DateTime` is not defined and `object` is `false`, (e.g. `expect(x).to eq false`): in that case it will call `format_date_time` even thought it's `false` and not a `DateTime`.

I think it's better to use an explicit `if` statement:

``` ruby
return format_time(object) if Time === object
return format_date_time(object) if defined?(DateTime) && DateTime === object
object.inspect
```