Skip to content

Instantly share code, notes, and snippets.

@ELLIOTTCABLE
Created September 30, 2008 01:44
Show Gist options
  • Save ELLIOTTCABLE/13722 to your computer and use it in GitHub Desktop.
Save ELLIOTTCABLE/13722 to your computer and use it in GitHub Desktop.
class Foo
# Both setter and accessor
def on_paste
if block_given?
@on_paste = Proc.new # Implicit &block.to_proc
else
@on_paste
end
end
def initialize
yield self if block_given?
end
end
f = Foo.new do |f|
on_paste do
p 'yay'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment