Skip to content

Instantly share code, notes, and snippets.

@brentkirby
Created May 12, 2011 02:27
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 brentkirby/967822 to your computer and use it in GitHub Desktop.
Save brentkirby/967822 to your computer and use it in GitHub Desktop.
Random examples
class Bob
def self.blocky
yield
end
end
module Death
def call_blocky
Bob.blocky do
puts self
end
end
end
class Another
include Death
end
# Another.new.call_blocky #=> #<Another:0x000001009c10e8>
class Runnee
def self.called
puts self
end
end
class Middle
def self.caller(&block)
runner = Runnee.new
runner.instance_exec &block
end
end
class Runner < Middle
def self.doit
caller do
called
end
end
end
# Runner.doit #=> #<Runnee:0x000001009c73a8>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment