This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
## | |
# This is script with usefull tips taken from: | |
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx | |
# | |
# install it: | |
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# I need class C to call the foo method for each module included | |
# that has the method foo. Order does not matter as much as each | |
# method getting called. alias method chain? | |
module ChainMethod | |
def chain_method(method_name) | |
base_method = instance_method(method_name.to_sym) | |
chained_method = included_modules.inject([base_method]) do |mem, mod| | |
if method = (mod.instance_methods.include?(method_name.to_s) ? mod.instance_method(method_name.to_sym) : nil) | |
mem << method | |
end |