class RuboCop::Cop::Style::MissingRespondToMissing
This cop checks for the presence of `method_missing` without also defining `respond_to_missing?`.
@example
#bad def method_missing(name, *args) # ... end #good def respond_to_missing?(name, include_private) # ... end def method_missing(name, *args) # ... end
Constants
- MSG
Public Instance Methods
on_def(node)
click to toggle source
# File lib/rubocop/cop/style/missing_respond_to_missing.rb, line 28 def on_def(node) return unless node.method?(:method_missing) return if implements_respond_to_missing?(node) add_offense(node) end
Also aliased as: on_defs
Private Instance Methods
implements_respond_to_missing?(node)
click to toggle source
# File lib/rubocop/cop/style/missing_respond_to_missing.rb, line 38 def implements_respond_to_missing?(node) node.parent.each_child_node(node.type).any? do |sibling| sibling.method?(:respond_to_missing?) end end