public
Rubygem
Description: ObjectProxy provides a proxied interface to Ruby objects. It lets you add methods to objects that don't normally support them.
Homepage: http://6brand.com
Clone URL: git://github.com/JackDanger/object_proxy.git
commit  cad9db585a5f9da17a3878d44e6b37dc30acc160
tree    83071e4b9d6741090ecb91f6b0b952fc3ac9d1c3
parent  1713af91d8eed42f75f2f9cd9421af5cb9360d05
name age message
file History.txt Thu Mar 06 05:46:31 -0800 2008 version bump. [JackDanger]
file Manifest.txt Thu Mar 06 05:30:47 -0800 2008 Revert "fixing manifest" [JackDanger]
file README.txt Wed Mar 05 22:19:55 -0800 2008 add all files to git [JackDanger]
file Rakefile Thu Mar 06 05:39:21 -0800 2008 using the root level for rdoc generation. hoe ... [JackDanger]
directory lib/ Thu Mar 06 05:46:31 -0800 2008 version bump. [JackDanger]
directory test/ Thu Mar 06 05:47:33 -0800 2008 looks like my clever rename broke the 'rake tes... [JackDanger]
README.txt
= ObjectProxy

* http://github.com/JackDanger/object_proxy/tree/master

== DESCRIPTION

ObjectProxy provides a proxied interface to Ruby objects.  It lets you add methods to objects that don't normally 
support them.

== USAGE

A simple extension to a fixnum:

    fixnum = ObjectProxy.new(1234)
    # => 1234
    fixnum.proxy_class.class_eval do
     define_method :hi_there do
       'Ahoy!'
     end
    end
    # => #<Proc:0x018f58f8>
    fixnum.size
    # => 4
    fixnum.hi_there
    # => Ahoy!

A more complex example where a string is able to update itself from a text file

    class FetchedString < ObjectProxy
      def initialize(target, filename)
        @target = target
        @filename = filename
      end
      
      def update
        @target = File.read(filename)
      end
    end
    
    # write a string into a file
    File.open('/tmp/greeting.txt', 'w') {|f| f.write('welcome')}
    
    string = FetchedString.new('hey there', '/tmp/greeting.txt')
    # => 'hey there'
    string.class
    # => String
    string.update
    # => 'welcome'


== INSTALL:

* sudo gem install object_proxy

== LICENSE:

(The MIT License)

Copyright (c) 2008 FIX

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.