Skip to content

Instantly share code, notes, and snippets.

@britishtea
Created April 13, 2016 09:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save britishtea/6fb9153a26825cc7219ef2a9da5ba8c0 to your computer and use it in GitHub Desktop.
Save britishtea/6fb9153a26825cc7219ef2a9da5ba8c0 to your computer and use it in GitHub Desktop.
class Foo
def self.bar(&block)
instance_exec(&block)
end
attr_accessor :x
end
Foo.bar do
x = 5
end
class Foo
def self.bar(&block)
yield(self)
end
attr_accessor :x
end
Foo.bar do |foo|
foo.x = 5
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment