Skip to content

Instantly share code, notes, and snippets.

@osyo-manga
Created November 24, 2015 04:11
Show Gist options
  • Select an option

  • Save osyo-manga/876da85a23a53e9a5ba2 to your computer and use it in GitHub Desktop.

Select an option

Save osyo-manga/876da85a23a53e9a5ba2 to your computer and use it in GitHub Desktop.
call_once
def call_one &block
flag = false
proc { flag || instance_eval(&block); flag = true }
end
class X
define_method(:initialize, &call_one do
p "homu"
end)
end
X.new
X.new
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment