Skip to content

Instantly share code, notes, and snippets.

@beakr
Created April 20, 2013 17:45
Show Gist options
  • Save beakr/5426791 to your computer and use it in GitHub Desktop.
Save beakr/5426791 to your computer and use it in GitHub Desktop.
Find out if a module includes a method.
module C
def bananas
puts :Bananas!
end
end
def include_method?(method, mod)
if mod.methods.include? method
puts "Module #{mod} has method #{method}"
true
else
puts "Module #{mod} doesn't have method #{method}!"
false
end
end
include_method? :bananas, C
include_method? :trololol, C
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment