How to the get limit value when user passes Model.limit(10)

Hi,

when the user calls Model.limit(10) I want is get the value of 10.

So for that, I have overloaded a function

def visit_Arel_Nodes_SelectStatement(o, collector)
    if o.limit
      limcoll = Arel::Collectors::SQLString.new
      visit o.limit, limcoll
       puts "#{limcoll}"
    end
end

This was working till rails 4 but it was not working in rails 6 (It prints ?)

I was trying to fix it for a long time but not succeeded
Can anyone please help me? what is the mistake I am doing?

Thanks,
Akhil