Sha256: 2a65578e470d9a2d08a49bfc0d1fdcf0b3607e6cdb7b9e68d124ad0da70b500c

Contents?: true

Size: 926 Bytes

Versions: 40

Compression:

Stored size: 926 Bytes

Contents

module Yao
  module Mode
    def read_only!(&blk)
      raise unless block_given?

      raise_on_write_org = Yao.config.raise_on_write
      noop_on_write_org  = Yao.config.noop_on_write

      Yao.config.set :noop_on_write, false if noop_on_write_org
      Yao.config.set :raise_on_write, true
      begin
        yield
      ensure
        Yao.config.set :raise_on_write, raise_on_write_org
        Yao.config.set :noop_on_write,  noop_on_write_org
      end
    end

    def read_only(&blk)
      raise unless block_given?

      noop_on_write_org  = Yao.config.noop_on_write
      raise_on_write_org = Yao.config.raise_on_write

      Yao.config.set :raise_on_write, false if raise_on_write_org
      Yao.config.set :noop_on_write, true
      begin
        yield
      ensure
        Yao.config.set :noop_on_write,  noop_on_write_org
        Yao.config.set :raise_on_write, raise_on_write_org
      end
    end
  end
end

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
yao-0.13.4 lib/yao/mode.rb
yao-0.13.3 lib/yao/mode.rb
yao-0.13.2 lib/yao/mode.rb
yao-0.13.1 lib/yao/mode.rb
yao-0.13.0 lib/yao/mode.rb
yao-0.12.0 lib/yao/mode.rb
yao-0.11.3 lib/yao/mode.rb
yao-0.11.2 lib/yao/mode.rb
yao-0.11.1 lib/yao/mode.rb
yao-0.11.0 lib/yao/mode.rb
yao-0.10.1 lib/yao/mode.rb
yao-0.10.0 lib/yao/mode.rb
yao-0.9.1 lib/yao/mode.rb
yao-0.9.0 lib/yao/mode.rb
yao-0.8.0 lib/yao/mode.rb
yao-0.7.0 lib/yao/mode.rb
yao-0.6.3 lib/yao/mode.rb
yao-0.6.2 lib/yao/mode.rb
yao-0.6.1 lib/yao/mode.rb
yao-0.6.0 lib/yao/mode.rb