Skip to content

Instantly share code, notes, and snippets.

@pjg
Created November 22, 2011 10:40
Show Gist options
  • Save pjg/1385392 to your computer and use it in GitHub Desktop.
Save pjg/1385392 to your computer and use it in GitHub Desktop.
Metaprogramming fu

I have:

def self.host
  @@host ||= something
end

now I want to convert it into this:

class << self
  defined_method "host" do
    class_variable_set ????

how do I "convert" ||= to class_variable_set ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment