ext/rubyvm/lib/forwardable/impl.rb
raw| 1 | # :stopdoc: |
| 2 | module Forwardable |
| 3 | def self._valid_method?(method) |
| 4 | iseq = RubyVM::InstructionSequence.compile("().#{method}", nil, nil, 0, false) |
| 5 | rescue SyntaxError |
| 6 | false |
| 7 | else |
| 8 | iseq.to_a.dig(-1, 1, 1, :mid) == method.to_sym |
| 9 | end |
| 10 | |
| 11 | def self._compile_method(src, file, line) |
| 12 | RubyVM::InstructionSequence.compile(src, file, file, line, |
| 13 | trace_instruction: false) |
| 14 | .eval |
| 15 | end |
| 16 | end |