Created
August 1, 2012 15:24
-
-
Save nnabeyang/3227790 to your computer and use it in GitHub Desktop.
railsのEngine, Applicationはclass Cのようにメソッドが無い場合は、インスタンスメソッドを実行する
This file contains hidden or 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
| module Configurable | |
| def instance | |
| @instance ||= new | |
| end | |
| def method_missing(*args, &block) | |
| instance.send(*args, &block) | |
| end | |
| end | |
| class C | |
| extend Configurable | |
| def say_hello name | |
| puts "hello #{name}" | |
| end | |
| end | |
| C.say_hello "nabeyang" #=> hello nabeyang |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment