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

Changeset 3314

Show
Ignore:
Timestamp:
12/15/05 20:03:23 (3 years ago)
Author:
sam
Message:

Add Object#with_options for DRYing up multiple calls to methods having shared options

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/activesupport/CHANGELOG

    r3190 r3314  
    11*SVN* 
     2 
     3* Add Object#with_options for DRYing up multiple calls to methods having shared options. [Sam Stephenson]  Example: 
     4 
     5  ActionController::Routing::Routes.draw do |map| 
     6    # Account routes 
     7    map.with_options(:controller => 'account') do |account| 
     8      account.home   '',       :action => 'dashboard' 
     9      account.signup 'signup', :action => 'new' 
     10      account.logout 'logout', :action => 'logout' 
     11    end 
     12  end 
    213 
    314* Introduce Dependencies.warnings_on_first_load setting.  If true, enables warnings on first load of a require_dependency.  Otherwise, loads without warnings.  Disabled (set to false) by default.  [Jeremy Kemper] 
  • trunk/activesupport/lib/active_support.rb

    r2421 r3314  
    3333 
    3434require 'active_support/ordered_options' 
     35require 'active_support/option_merger' 
    3536 
    3637require 'active_support/values/time_zone' 
  • trunk/activesupport/lib/active_support/core_ext/object_and_class.rb

    r3113 r3314  
    5151    end 
    5252  end 
     53   
     54  def with_options(options) 
     55    yield ActiveSupport::OptionMerger.new(self, options) 
     56  end 
    5357end 
    5458