Class: MySQLNoIo::Wrap

Inherits:
Object
  • Object
show all
Defined in:
lib/mysqlnoio/wrap.rb

Overview

A wrap represents a open/close block which always runs a before and an after statement.

Passing a block to #execute will execute the block from between the statements.

Example:

class FooWrap
  def execute &block
    puts "Hi"

    yeild(block)
  ensure
    puts "Bye"
  end
end

foo = FooWrap.new()
foo.execute do
  puts "Ahh! Safety!"
end

Will output: Hi Ahh! Safety! Bye