Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #4133 (closed defect: worksforme)

Opened 2 years ago

Last modified 1 year ago

documentation for delegate mixin

Reported by: court3nay Assigned to: David
Priority: normal Milestone:
Component: ActiveSupport Version: 1.0.0
Severity: normal Keywords:
Cc: documentation

Description

add some basic information about this handy helper

 # Delegate simply delegates a method to another class.
  # This is useful if you have a lot of cases where you are referring to fields in
  # associated classes: for example,
  # class Banana < ActiveRecord::Base
  #   belongs_to :monkey
  #   def name
  #     monkey.name
  #   end
  # end
  #
  # Usage:
  # class Banana < ActiveRecord::Base
  #   delegate :name, :to => :monkey
  # end
  #
  # You can also use delegate on a has_many association; if Banana has_many :worms,
  # then use
  #   delegate :name, :to => 'worms.first'
  #
  # which is effectively the same as
  #   def name
  #     worms.first.name
  #   end
  #

Attachments

delegate_docs.diff (1.2 kB) - added by court3nay@gmail.com on 03/08/06 06:34:30.

Change History

03/08/06 06:34:30 changed by court3nay@gmail.com

  • attachment delegate_docs.diff added.

01/20/07 00:59:32 changed by manfred

  • status changed from new to closed.
  • resolution set to worksforme.

Delegate was documented somewhere between 11 months ago and now.