What am I missing here

#Warning, the below is pseudo code, the conditionals are all that count

for column in Class.content_columns

column.type output: Time

column.klass output: Time

column.is_a?(Time) false
column.type.is_a?(Time) false
column.klass.is_a?(Time) false
column.type.kind_of?(Time) false
column.klass.kind_of?(Time) false
column.type == Time false

column.klass == Time true

I know I’m missing something obvious…but that’s a lot of “type
testing” and I can’t see for the life of me why column.klass == Time
evaluates to true when column.klass.kind_of or is_a? evaluates to false

First, Object#type is deprecated (use Object#class) instead. AR
overrides type to provied the active record type ie string, datetime
etc…
class gives you the actual class, on my machine I get something like
ActiveRecord::ConnectionAdapters::MysqlColumn

Secondly, assuming a.class == Time, why should a.class.kind_of?(Time) be
true ?
a.class is an instance of Class, not an instance of Time

Fred

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs