public
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
JackDanger (author)
Sun Oct 11 19:48:10 -0700 2009
commit  7a00e65ec33d6d65bdb8b7ae5901965d13abe29b
tree    0afbb6a3f2b921b67b2c99f7d3b26b1ccc99b151
parent  70ef615072b65344e7db35ec1c7ca3045ed484e0
name age message
file History.txt Thu Mar 06 15:26:03 -0800 2008 rename and version bump [JackDanger]
file Manifest.txt Thu Mar 19 11:07:29 -0700 2009 updating Manifest [JackDanger]
file README.txt Wed Mar 05 22:19:55 -0800 2008 add all files to git [JackDanger]
file Rakefile Wed Mar 04 12:15:09 -0800 2009 fixing my email address [JackDanger]
file init.rb Thu Mar 06 13:41:49 -0800 2008 pluginifying the ObjectProxy gem [JackDanger]
file install.rb Thu Mar 06 13:41:49 -0800 2008 pluginifying the ObjectProxy gem [JackDanger]
directory lib/ Sun Oct 11 19:45:44 -0700 2009 fixing incompatablility with pp.rb [JackDanger]
file object_proxy.gemspec Sun Oct 11 19:48:10 -0700 2009 adding gemspec [JackDanger]
directory rails/ Thu Mar 27 13:11:10 -0700 2008 Configuring for Rails GemLocator [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.