Skip to content

Instantly share code, notes, and snippets.

@siassaj

siassaj/thing.rb Secret

Last active March 29, 2016 03:58
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 siassaj/618e3230f713fb1fc26d to your computer and use it in GitHub Desktop.
Save siassaj/618e3230f713fb1fc26d to your computer and use it in GitHub Desktop.
# something like
a_special_object = Object.new do
class << self
def make_noise
"noise!"
end
end
end
# instead of
another_special_object = Object.new
def another_special_object.say_hi
"hi"
end
# although this works and is not so bad
a_third_special_object = Object.new.tap do |o|
def o.make_noise
"noise!"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment