public
Description: A Ruby library for quickly creating proxy objects.
Homepage:
Clone URL: git://github.com/yfactorial/roxy.git
roxy /
name age message
file .gitignore Thu Nov 13 18:57:20 -0800 2008 Start on allowing methods with arguments to be ... [rwdaigle]
file CHANGELOG Sun Nov 09 10:39:27 -0800 2008 Initial stab at proxy library [rwdaigle]
file LICENSE Sun Nov 09 10:39:27 -0800 2008 Initial stab at proxy library [rwdaigle]
file README.textile Mon Nov 10 13:31:31 -0800 2008 Added announcement post url [rwdaigle]
file Rakefile Sun Nov 09 10:39:27 -0800 2008 Initial stab at proxy library [rwdaigle]
file init.rb Sun Nov 09 10:39:27 -0800 2008 Initial stab at proxy library [rwdaigle]
directory lib/ Sat Nov 22 07:27:41 -0800 2008 Made proxy method more concise [rwdaigle]
file roxy.gemspec Sat Nov 22 07:29:14 -0800 2008 Update gem version [rwdaigle]
directory spec/ Fri Nov 14 06:20:24 -0800 2008 Added ability to proxy methods with arguments [rwdaigle]
README.textile

Roxy (A ruby proxy library)

Summary

Roxy is a basic proxy library that lets you quickly create proxies between your ruby objects. Its syntax
is loosely based on Association Extensions in ActiveRecord
as that is a well-known use of proxies.

Please see the CHANGELOG for contribution details.

Roxy has the following dependencies:

  • rspec >= 1.1.4 (for specs only, not runtime)

Installation

To install the roxy gem run the following:

sudo gem install yfactorial-roxy —source http://gems.github.com

And to enable the scopes in your project just require the roxy library and give your object some moxie:

require ‘roxy’ class Person include Roxy::Moxie … end

Usage

See the announcement post for detailed usage examples: http://ryandaigle.com/articles/2008/11/10/implement-ruby-proxy-objects-with-roxy

Here’s a basic example:


  require 'roxy'
  class Person
    include Roxy::Moxie    
    
    attr_accessor :first, :last, :parents 
       
    proxy :parents do
      def divorced?
        proxy_target.size > 1 and proxy_target.collect { |parent| parent.last }.uniq.size > 1
      end
    end
  end

  # Can then invoke your proxy methods directly on parents
  person.parents.divorced?