Created
December 8, 2014 09:34
-
-
Save Avene/8630870f536d088a8e4a to your computer and use it in GitHub Desktop.
add instance-specific method
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
# オブジェクトにmessageメソッドを追加して返す | |
def add_message(obj, cause) | |
(class << obj; self; end).class_eval do | |
define_method(:message) { " #{cause}" } | |
end | |
obj | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment