Module: Frubby::RespondToMissing

Defined in:
lib/frubby/respond_to_missing.rb

Constant Summary collapse

EXCLUDED_RESPOND_TOS =
i[
  begin
  end
  path
  to_ary
  to_io
  to_hash
  to_str
]
KERNEL_METHODS =
Kernel.methods.delete_if {|m| m.match /^[A-Z]/}

Instance Method Summary collapse

Instance Method Details

#respond_to_missing?(method_name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
19
20
21
22
23
24
25
# File 'lib/frubby/respond_to_missing.rb', line 16

def respond_to_missing?(method_name, include_private = false)
  return super if EXCLUDED_RESPOND_TOS.include? method_name.to_sym

  _methods = KERNEL_METHODS + methods
  _method = FuzzyMatch.new(_methods).find(method_name.to_sym)
  
  warn "[frubby] respond_to_missing: #{method_name} ~> #{_method}" if $DEBUG

  _method.is_a?(Symbol) ? true : super
end