Skip to content

Instantly share code, notes, and snippets.

@nnabeyang
Created August 1, 2012 15:24
Show Gist options
  • Select an option

  • Save nnabeyang/3227790 to your computer and use it in GitHub Desktop.

Select an option

Save nnabeyang/3227790 to your computer and use it in GitHub Desktop.
railsのEngine, Applicationはclass Cのようにメソッドが無い場合は、インスタンスメソッドを実行する
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