0.0
No commit activity in last 3 years
No release in over 3 years
Use this as a channel to execute methods from another object, stash'em up but do not run until you are certain.. or clear the whole stack of execution. then start over.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.0.0
~> 1.8.3
>= 0
~> 3.12
 Project Readme

buffered_proxy¶ ↑

A proxy that thinks she’s a buffer.

Abstract¶ ↑

Use this as a channel to execute methods from another object, stash’em up but do not run until you are certain.. or clear the whole stack of execution. then start over.

Usage¶ ↑

require 'rubygems'
require 'buffered_proxy'

class Target

  def initialize(string)
    @string = string
  end

  def print
    puts @string
  end

  def change string
    @string = string
  end

end

target = Target.new('Hello')
proxy = BufferedProxy.new(target, [:print, :change])

# Print the message twice
proxy.print
proxy.print
proxy.flush # Execute every instruction given, and clear the stack
            # so we start from zero from this point on..

# Do some stuff with the proxy, and then discard everything!
proxy.print
proxy.change 'this should never execute'
proxy.print
proxy.clear # Clean everything in the stack without running anything

# Start fresh now, print old message, change it and print it again.
proxy.print
proxy.change 'Good bye'
proxy.print
proxy.flush # Execute every instruction given, and clear the stack
            # so we start from zero from this point on..

proxy.flush # Since the stack is clean now this shall not execute
            # anythig!

The script above will output this.

Hello
Hello
Hello
Good bye