diff options
Diffstat (limited to 'activesupport/lib/active_support/core_ext/object/with_options.rb')
-rw-r--r-- | activesupport/lib/active_support/core_ext/object/with_options.rb | 15 |
1 files changed, 7 insertions, 8 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 e058367111..42e388b065 100644 --- a/activesupport/lib/active_support/core_ext/object/with_options.rb +++ b/activesupport/lib/active_support/core_ext/object/with_options.rb @@ -10,16 +10,16 @@ class Object # Without <tt>with_options></tt>, this code contains duplication: # # class Account < ActiveRecord::Base - # has_many :customers, :dependent => :destroy - # has_many :products, :dependent => :destroy - # has_many :invoices, :dependent => :destroy - # has_many :expenses, :dependent => :destroy + # has_many :customers, dependent: :destroy + # has_many :products, dependent: :destroy + # has_many :invoices, dependent: :destroy + # has_many :expenses, dependent: :destroy # end # # Using <tt>with_options</tt>, we can remove the duplication: # # class Account < ActiveRecord::Base - # with_options :dependent => :destroy do |assoc| + # with_options dependent: :destroy do |assoc| # assoc.has_many :customers # assoc.has_many :products # assoc.has_many :invoices @@ -29,14 +29,13 @@ class Object # # It can also be used with an explicit receiver: # - # I18n.with_options :locale => user.locale, :scope => 'newsletter' do |i18n| + # I18n.with_options locale: user.locale, scope: 'newsletter' do |i18n| # subject i18n.t :subject - # body i18n.t :body, :user_name => user.name + # 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 |