This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
| name | age | message | |
|---|---|---|---|
| |
MIT-LICENSE | Sat Sep 20 05:48:02 -0700 2008 | |
| |
README.markdown | Sat Sep 20 05:48:02 -0700 2008 | |
| |
Rakefile | Sat Sep 20 05:48:02 -0700 2008 | |
| |
init.rb | Sat Sep 20 05:48:02 -0700 2008 | |
| |
install.rb | Sat Sep 20 05:48:02 -0700 2008 | |
| |
lib/ | Sat Sep 20 05:48:02 -0700 2008 | |
| |
tasks/ | Sat Sep 20 05:48:02 -0700 2008 | |
| |
test/ | Sat Sep 20 05:48:02 -0700 2008 | |
| |
uninstall.rb | Sat Sep 20 05:48:02 -0700 2008 |
Hyperdelegate
Implementation as a plugin of this patch for Rails.
[PATCH] More options to make delegate more flexible
Adds two options to delegate to make it more flexible and support two frequent patterns in delegation.
You can specify a target if you don't want your method to have the same name:
class Foo < ActiveRecord::Base
belongs_to :greeter
delegate :hi, :to => :greeter, :target => :hello
end
Foo.new.hi # returns Foo.new.greeter.hello
If the object in which you delegate can be nil, you may want to use the :allow_nil option. In that case, it returns nil instead of raising a NoMethodError exception:
class Foo
def initialize(bar = nil)
@bar = bar
end
delegate :zoo, :to => :bar
end
Foo.new.zoo # raises NoMethodError exception (you called nil.zoo)
class Foo
def initialize(bar = nil)
@bar = bar
end
delegate :zoo, :to => :bar, :allow_nil => true
end
Foo.new.zoo # returns nil
Copyright (c) 2008 Sergio Gil, released under the MIT license











