Skip to content

Instantly share code, notes, and snippets.

@headius
Created August 4, 2010 19:54
Show Gist options
  • Save headius/508688 to your computer and use it in GitHub Desktop.
Save headius/508688 to your computer and use it in GitHub Desktop.
old code:
code = <<-code
def #{ name }!
initializer = ObjectSpace._id2ref #{ initializer_id }
self.#{ name } = initializer.call(self)
@#{ name }
end
code
compile[code]
new code:
module_eval do
define_method :"#{ name }!" do
self.send :"#{ name }=", initializer.call(self)
self.instance_variable_get :"@#{name}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment