Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

:args option for run_callbacks

#589

Patch attached, here's the branch

#   * +:args+ - Pass the provided arguments array to each callback method or proc.
#     Arguments that exeed the arity of the callback method/proc will be silently
#     discarded rather then generate a warning. String callbacks cannot receieve
#     arguments. (default: +[]+ i.e. no arguments will be passed)

Example:

  def investigate(suspect)
    run_callback :before_investigation, :args=>[suspect]
    # ...
    run_callback :after_investigation, :args=>[suspect]
  end
  
  before_investigation :plant_evidence
  after_investigation :testify_in_court

  def plant_evidence(suspect)
    suspect.plant(INCRIMINATING_STUFF)
  end
  
  def testify_in_court
    # ... 
    # Note i don't need to expect the (suspect) arg if I'm not going to use it
  end
end

Reported by Ruy Asan · July 10th, 2008 @ 01:34 AM

State: wontfix
Milestone: 2.x
Assigned to: nobody
Importance: none

Activity

  1. josh
    josh
    • State changed from new to wontfix

    If you want to pass multiple options, just use a hash.

    July 13th, 2008 @ 08:39 PM