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.5.0 lib/yao/mode.rb
yao-0.4.3 lib/yao/mode.rb
yao-0.4.2 lib/yao/mode.rb
yao-0.4.1 lib/yao/mode.rb
yao-0.4.0 lib/yao/mode.rb
yao-0.3.8 lib/yao/mode.rb
yao-0.3.7 lib/yao/mode.rb
yao-0.3.6 lib/yao/mode.rb
yao-0.3.5 lib/yao/mode.rb
yao-0.3.4 lib/yao/mode.rb
yao-0.3.3 lib/yao/mode.rb
yao-0.3.2 lib/yao/mode.rb
yao-0.3.1 lib/yao/mode.rb
yao-0.3.0 lib/yao/mode.rb
yao-0.2.13 lib/yao/mode.rb
yao-0.2.12 lib/yao/mode.rb
yao-0.2.11 lib/yao/mode.rb
yao-0.2.10 lib/yao/mode.rb
yao-0.2.9 lib/yao/mode.rb
yao-0.2.8 lib/yao/mode.rb