From 8270dcd12e2892147002b23e80e3a25ab45a1e25 Mon Sep 17 00:00:00 2001 From: Ben Orenstein Date: Sat, 26 Feb 2011 12:59:27 -0500 Subject: Correct example that did not do what it claimed. Rework explanation. --- .../lib/active_support/core_ext/hash/reverse_merge.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'activesupport/lib/active_support/core_ext') diff --git a/activesupport/lib/active_support/core_ext/hash/reverse_merge.rb b/activesupport/lib/active_support/core_ext/hash/reverse_merge.rb index a82cdfc360..87a7bebd7b 100644 --- a/activesupport/lib/active_support/core_ext/hash/reverse_merge.rb +++ b/activesupport/lib/active_support/core_ext/hash/reverse_merge.rb @@ -6,14 +6,14 @@ class Hash # options.reverse_merge! :size => 25, :velocity => 10 # end # - # Using merge, the above example would look as follows: + # The default :size and :velocity are only set if the +options+ hash passed in doesn't already + # have the respective key. + # + # As contrast, using Ruby's built in merge would require writing the following: # # def setup(options = {}) - # { :size => 25, :velocity => 10 }.merge(options) + # options = { :size => 25, :velocity => 10 }.merge(options) # end - # - # The default :size and :velocity are only set if the +options+ hash passed in doesn't already - # have the respective key. def reverse_merge(other_hash) other_hash.merge(self) end -- cgit v1.2.3 From e872a8f2a5c2f9127b9b15a60ba37d5a21e9f6cb Mon Sep 17 00:00:00 2001 From: Ben Orenstein Date: Sat, 26 Feb 2011 13:36:47 -0500 Subject: Example descriptions and their examples were flipped. Fix. --- activesupport/lib/active_support/core_ext/string/filters.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'activesupport/lib/active_support/core_ext') diff --git a/activesupport/lib/active_support/core_ext/string/filters.rb b/activesupport/lib/active_support/core_ext/string/filters.rb index e15a1df9c9..d478ee0ef6 100644 --- a/activesupport/lib/active_support/core_ext/string/filters.rb +++ b/activesupport/lib/active_support/core_ext/string/filters.rb @@ -25,13 +25,13 @@ class String # "Once upon a time in a world far far away".truncate(27) # # => "Once upon a time in a wo..." # - # The last characters will be replaced with the :omission string (defaults to "...") - # for a total length not exceeding :length: + # Pass a :separator to truncate +text+ at a natural break: # # "Once upon a time in a world far far away".truncate(27, :separator => ' ') # # => "Once upon a time in a..." # - # Pass a :separator to truncate +text+ at a natural break: + # The last characters will be replaced with the :omission string (defaults to "...") + # for a total length not exceeding :length: # # "And they found that many people were sleeping better.".truncate(25, :omission => "... (continued)") # # => "And they f... (continued)" -- cgit v1.2.3 From 8f13a166ceda779357d1c356776a11086f7ee146 Mon Sep 17 00:00:00 2001 From: Ben Orenstein Date: Sat, 26 Feb 2011 14:29:22 -0500 Subject: Clarify comment by removing french reference ('a la'). Should improve readability for non-native english speakers. --- activesupport/lib/active_support/core_ext/enumerable.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activesupport/lib/active_support/core_ext') diff --git a/activesupport/lib/active_support/core_ext/enumerable.rb b/activesupport/lib/active_support/core_ext/enumerable.rb index 6ecedc26ef..6d7f771b5d 100644 --- a/activesupport/lib/active_support/core_ext/enumerable.rb +++ b/activesupport/lib/active_support/core_ext/enumerable.rb @@ -94,7 +94,7 @@ module Enumerable end # Returns true if the collection has more than 1 element. Functionally equivalent to collection.size > 1. - # Works with a block too ala any?, so people.many? { |p| p.age > 26 } # => returns true if more than 1 person is over 26. + # Can be called with a block too, much like any?, so people.many? { |p| p.age > 26 } returns true if more than 1 person is over 26. def many?(&block) size = block_given? ? select(&block).size : self.size size > 1 -- cgit v1.2.3 From 108561f1cb73c0f600db6cad10b7cf03bf90f09f Mon Sep 17 00:00:00 2001 From: "Jonathon D. Jones" Date: Thu, 3 Mar 2011 18:10:33 -0500 Subject: Adds link to Object.blank? from Object.present? --- activesupport/lib/active_support/core_ext/object/blank.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activesupport/lib/active_support/core_ext') diff --git a/activesupport/lib/active_support/core_ext/object/blank.rb b/activesupport/lib/active_support/core_ext/object/blank.rb index 51670b148f..f70853073a 100644 --- a/activesupport/lib/active_support/core_ext/object/blank.rb +++ b/activesupport/lib/active_support/core_ext/object/blank.rb @@ -13,7 +13,7 @@ class Object respond_to?(:empty?) ? empty? : !self end - # An object is present if it's not blank. + # An object is present if it's not #blank?. def present? !blank? end -- cgit v1.2.3 From 80e3beb24b3fa7fad03486bd4f168f45377a8a60 Mon Sep 17 00:00:00 2001 From: "R.T. Lechow" Date: Thu, 3 Mar 2011 23:14:18 -0500 Subject: Active Support typos. --- activesupport/lib/active_support/core_ext/object/try.rb | 2 +- activesupport/lib/active_support/core_ext/string/multibyte.rb | 2 +- activesupport/lib/active_support/core_ext/string/output_safety.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'activesupport/lib/active_support/core_ext') diff --git a/activesupport/lib/active_support/core_ext/object/try.rb b/activesupport/lib/active_support/core_ext/object/try.rb index ff812234e3..04619124a1 100644 --- a/activesupport/lib/active_support/core_ext/object/try.rb +++ b/activesupport/lib/active_support/core_ext/object/try.rb @@ -21,7 +21,7 @@ class Object # Person.try(:find, 1) # @people.try(:collect) {|p| p.name} # - # Without a method argument try will yield to the block unless the reciever is nil. + # Without a method argument try will yield to the block unless the receiver is nil. # @person.try { |p| "#{p.first_name} #{p.last_name}" } #-- # +try+ behaves like +Object#send+, unless called on +NilClass+. diff --git a/activesupport/lib/active_support/core_ext/string/multibyte.rb b/activesupport/lib/active_support/core_ext/string/multibyte.rb index 0b974f5e0a..41de4d6435 100644 --- a/activesupport/lib/active_support/core_ext/string/multibyte.rb +++ b/activesupport/lib/active_support/core_ext/string/multibyte.rb @@ -9,7 +9,7 @@ class String # # In Ruby 1.8 and older it creates and returns an instance of the ActiveSupport::Multibyte::Chars class which # encapsulates the original string. A Unicode safe version of all the String methods are defined on this proxy - # class. If the proxy class doesn't respond to a certain method, it's forwarded to the encapsuled string. + # class. If the proxy class doesn't respond to a certain method, it's forwarded to the encapsulated string. # # name = 'Claus Müller' # name.reverse # => "rell??M sualC" diff --git a/activesupport/lib/active_support/core_ext/string/output_safety.rb b/activesupport/lib/active_support/core_ext/string/output_safety.rb index c930abc003..addd4dab95 100644 --- a/activesupport/lib/active_support/core_ext/string/output_safety.rb +++ b/activesupport/lib/active_support/core_ext/string/output_safety.rb @@ -24,7 +24,7 @@ class ERB end end - # Aliasing twice issues a warning "dicarding old...". Remove first to avoid it. + # Aliasing twice issues a warning "discarding old...". Remove first to avoid it. remove_method(:h) alias h html_escape -- cgit v1.2.3