Trying to inject my own function (say check) to Float class. When I am doing from a module it is not injected to Float class. Please see the following snippets.
irb(main):001:0> module QA
irb(main):002:1> class Float
irb(main):003:2> def self.check
irb(main):004:3> end
irb(main):005:2> end
irb(main):006:1> end
=> nil
irb(main):007:0> include QA
=> Object
irb(main):008:0> Float.respond_to?(:check)
=> false
irb(main):009:0> extend QA
=> main
irb(main):010:0> Float.respond_to?(:check)
=> false
irb(main):011:0> class Float
irb(main):012:1> def self.check
irb(main):013:2> end
irb(main):014:1> end
=> nil
irb(main):015:0> Float.respond_to?(:check)
=> true
This:
Is creating/modifying the class
QA::Float, notFloat. Try doingAnd you’ll see.
You could do something like this instead:
Some useful references:
class_evalincluded