Skip to content

Instantly share code, notes, and snippets.

@Avene
Created December 8, 2014 09:34
Show Gist options
  • Save Avene/8630870f536d088a8e4a to your computer and use it in GitHub Desktop.
Save Avene/8630870f536d088a8e4a to your computer and use it in GitHub Desktop.
add instance-specific method
# オブジェクトに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