module Pry::CodeObject::Helpers

def c_module?

Other tags:
    Note: - If a module defined by C was extended with a lot of methods written

Returns:
  • (Boolean) - `true` if this module was defined by means of the C API,
def c_module?
  return unless is_a?(WrappedModule)
  method_locations = wrapped.methods(false).map do |m|
    wrapped.method(m).source_location
  end
  method_locations.concat(
    wrapped.instance_methods(false).map do |m|
      wrapped.instance_method(m).source_location
    end
  )
  c_methods = method_locations.grep(nil).count
  ruby_methods = method_locations.count - c_methods
  c_methods > ruby_methods
end