aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/object
diff options
context:
space:
mode:
authorVijay Dev <vijaydev.cse@gmail.com>2011-05-07 21:18:03 +0530
committerVijay Dev <vijaydev.cse@gmail.com>2011-05-07 21:18:03 +0530
commit448845cd0dab1018f1bfc11dde5bbcd129abe93f (patch)
tree22475483ff009b61177bf56453e317756c90b13e /activesupport/lib/active_support/core_ext/object
parentffb70cf256e25965230af0e15ccb85e6e9f80bac (diff)
downloadrails-448845cd0dab1018f1bfc11dde5bbcd129abe93f.tar.gz
rails-448845cd0dab1018f1bfc11dde5bbcd129abe93f.tar.bz2
rails-448845cd0dab1018f1bfc11dde5bbcd129abe93f.zip
replaced eg using old router api with the one in the guides. Add info on nesting with_options
Diffstat (limited to 'activesupport/lib/active_support/core_ext/object')
-rw-r--r--activesupport/lib/active_support/core_ext/object/with_options.rb13
1 files changed, 8 insertions, 5 deletions
diff --git a/activesupport/lib/active_support/core_ext/object/with_options.rb b/activesupport/lib/active_support/core_ext/object/with_options.rb
index c23afabfdb..1397142c04 100644
--- a/activesupport/lib/active_support/core_ext/object/with_options.rb
+++ b/activesupport/lib/active_support/core_ext/object/with_options.rb
@@ -7,7 +7,7 @@ class Object
# provided. Each method called on the block variable must take an options
# hash as its final argument.
#
- # Without with_options, this code contains duplication:
+ # Without <tt>with_options></tt>, this code contains duplication:
#
# class Account < ActiveRecord::Base
# has_many :customers, :dependent => :destroy
@@ -16,7 +16,7 @@ class Object
# has_many :expenses, :dependent => :destroy
# end
#
- # Using with_options, we can remove the duplication:
+ # Using <tt>with_options</tt>, we can remove the duplication:
#
# class Account < ActiveRecord::Base
# with_options :dependent => :destroy do |assoc|
@@ -29,11 +29,14 @@ class Object
#
# It can also be used with an explicit receiver:
#
- # map.with_options :controller => "people" do |people|
- # people.connect "/people", :action => "index"
- # people.connect "/people/:id", :action => "show"
+ # I18n.with_options :locale => user.locale, :scope => "newsletter" do |i18n|
+ # subject i18n.t :subject
+ # body i18n.t :body, :user_name => user.name
# end
#
+ # <tt>with_options</tt> can also be nested since the call is forwarded to its receiver.
+ # Each nesting level will merge inherited defaults in addition to their own.
+ #
def with_options(options)
yield ActiveSupport::OptionMerger.new(self, options)
end