Search code examples
ruby

Why lazy load integer property result doesn't match Integer instance


I have the argument value which may be lazy load property actually it's got from BatchLoader library of Integer. The value behaves a bit strange when using case-expression. At convenience, Integer === (lose comparison) operator the results are,

[11] pry(ActiveJob::Arguments)> Integer === argument.to_i
=> true
[12] pry(ActiveJob::Arguments)> Integer === argument
=> false
[13] pry(ActiveJob::Arguments)> argument.is_a?(Integer)
=> true
[14] pry(ActiveJob::Arguments)> argument.class.name
=> "Integer"

Why is the second result false and is there a way to check where the argument is derived from?


Solution

  • As @tadman describes, our argument variable's methods is overwrited by the batch-loader library and it causes failure of comparison. We can check it by @tadman's solution. Thank you for that.