Skip to content

Commit 98bbfc0

Browse files
authored
Merge pull request rails#46512 from p8/activesupport/fix-code-example-spacing
Use 2 spaces for identation in ActiveSupport code examples [ci-skip]
2 parents 59f338b + 3d26ef2 commit 98bbfc0

File tree

10 files changed

+40
-39
lines changed

10 files changed

+40
-39
lines changed

activesupport/lib/active_support/core_ext/enumerable.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ def maximum(key)
5555

5656
# Calculates a sum from the elements.
5757
#
58-
# payments.sum { |p| p.price * p.tax_rate }
59-
# payments.sum(&:price)
58+
# payments.sum { |p| p.price * p.tax_rate }
59+
# payments.sum(&:price)
6060
#
6161
# The latter is a shortcut for:
6262
#
63-
# payments.inject(0) { |sum, p| sum + p.price }
63+
# payments.inject(0) { |sum, p| sum + p.price }
6464
#
6565
# It can also calculate the sum without the use of a block.
6666
#

activesupport/lib/active_support/core_ext/hash/deep_transform_values.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ class Hash
55
# This includes the values from the root hash and from all
66
# nested hashes and arrays.
77
#
8-
# hash = { person: { name: 'Rob', age: '28' } }
8+
# hash = { person: { name: 'Rob', age: '28' } }
99
#
10-
# hash.deep_transform_values{ |value| value.to_s.upcase }
11-
# # => {person: {name: "ROB", age: "28"}}
10+
# hash.deep_transform_values{ |value| value.to_s.upcase }
11+
# # => {person: {name: "ROB", age: "28"}}
1212
def deep_transform_values(&block)
1313
_deep_transform_values_in_object(self, &block)
1414
end

activesupport/lib/active_support/core_ext/hash/keys.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@ def assert_valid_keys(*valid_keys)
5858
# This includes the keys from the root hash and from all
5959
# nested hashes and arrays.
6060
#
61-
# hash = { person: { name: 'Rob', age: '28' } }
61+
# hash = { person: { name: 'Rob', age: '28' } }
6262
#
63-
# hash.deep_transform_keys{ |key| key.to_s.upcase }
64-
# # => {"PERSON"=>{"NAME"=>"Rob", "AGE"=>"28"}}
63+
# hash.deep_transform_keys{ |key| key.to_s.upcase }
64+
# # => {"PERSON"=>{"NAME"=>"Rob", "AGE"=>"28"}}
6565
def deep_transform_keys(&block)
6666
_deep_transform_keys_in_object(self, &block)
6767
end

activesupport/lib/active_support/core_ext/integer/inflections.rb

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,25 @@ class Integer
66
# Ordinalize turns a number into an ordinal string used to denote the
77
# position in an ordered sequence such as 1st, 2nd, 3rd, 4th.
88
#
9-
# 1.ordinalize # => "1st"
10-
# 2.ordinalize # => "2nd"
11-
# 1002.ordinalize # => "1002nd"
12-
# 1003.ordinalize # => "1003rd"
13-
# -11.ordinalize # => "-11th"
14-
# -1001.ordinalize # => "-1001st"
9+
# 1.ordinalize # => "1st"
10+
# 2.ordinalize # => "2nd"
11+
# 1002.ordinalize # => "1002nd"
12+
# 1003.ordinalize # => "1003rd"
13+
# -11.ordinalize # => "-11th"
14+
# -1001.ordinalize # => "-1001st"
1515
def ordinalize
1616
ActiveSupport::Inflector.ordinalize(self)
1717
end
1818

1919
# Ordinal returns the suffix used to denote the position
2020
# in an ordered sequence such as 1st, 2nd, 3rd, 4th.
2121
#
22-
# 1.ordinal # => "st"
23-
# 2.ordinal # => "nd"
24-
# 1002.ordinal # => "nd"
25-
# 1003.ordinal # => "rd"
26-
# -11.ordinal # => "th"
27-
# -1001.ordinal # => "st"
22+
# 1.ordinal # => "st"
23+
# 2.ordinal # => "nd"
24+
# 1002.ordinal # => "nd"
25+
# 1003.ordinal # => "rd"
26+
# -11.ordinal # => "th"
27+
# -1001.ordinal # => "st"
2828
def ordinal
2929
ActiveSupport::Inflector.ordinal(self)
3030
end

activesupport/lib/active_support/core_ext/object/duplicable.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ def duplicable?
3131
class Method
3232
# Methods are not duplicable:
3333
#
34-
# method(:puts).duplicable? # => false
35-
# method(:puts).dup # => TypeError: allocator undefined for Method
34+
# method(:puts).duplicable? # => false
35+
# method(:puts).dup # => TypeError: allocator undefined for Method
3636
def duplicable?
3737
false
3838
end
@@ -41,8 +41,8 @@ def duplicable?
4141
class UnboundMethod
4242
# Unbound methods are not duplicable:
4343
#
44-
# method(:puts).unbind.duplicable? # => false
45-
# method(:puts).unbind.dup # => TypeError: allocator undefined for UnboundMethod
44+
# method(:puts).unbind.duplicable? # => false
45+
# method(:puts).unbind.dup # => TypeError: allocator undefined for UnboundMethod
4646
def duplicable?
4747
false
4848
end
@@ -53,7 +53,7 @@ def duplicable?
5353
module Singleton
5454
# Singleton instances are not duplicable:
5555
#
56-
# Class.new.include(Singleton).instance.dup # TypeError (can't dup instance of singleton
56+
# Class.new.include(Singleton).instance.dup # TypeError (can't dup instance of singleton
5757
def duplicable?
5858
false
5959
end

activesupport/lib/active_support/error_reporter.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,12 @@ def subscribe(subscriber)
127127

128128
# Unregister an error subscriber. Accepts either a subscriber or a class.
129129
#
130-
# subscriber = MyErrorSubscriber.new
131-
# Rails.error.subscribe(subscriber)
130+
# subscriber = MyErrorSubscriber.new
131+
# Rails.error.subscribe(subscriber)
132132
#
133-
# Rails.error.unsubscribe(subscriber)
134-
# # or
135-
# Rails.error.unsubscribe(MyErrorSubscriber)
133+
# Rails.error.unsubscribe(subscriber)
134+
# # or
135+
# Rails.error.unsubscribe(MyErrorSubscriber)
136136
def unsubscribe(subscriber)
137137
@subscribers.delete_if { |s| subscriber === s }
138138
end

activesupport/lib/active_support/inflector/methods.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,8 +369,8 @@ def const_regexp(camel_cased_word)
369369
# If passed an optional +locale+ parameter, the uncountables will be
370370
# found for that locale.
371371
#
372-
# apply_inflections('post', inflections.plurals, :en) # => "posts"
373-
# apply_inflections('posts', inflections.singulars, :en) # => "post"
372+
# apply_inflections('post', inflections.plurals, :en) # => "posts"
373+
# apply_inflections('posts', inflections.singulars, :en) # => "post"
374374
def apply_inflections(word, rules, locale = :en)
375375
result = word.to_s.dup
376376

activesupport/lib/active_support/lazy_load_hooks.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def on_load(name, options = {}, &block)
6666
# Executes all blocks registered to +name+ via on_load, using +base+ as the
6767
# evaluation context.
6868
#
69-
# ActiveSupport.run_load_hooks(:active_record, ActiveRecord::Base)
69+
# ActiveSupport.run_load_hooks(:active_record, ActiveRecord::Base)
7070
#
7171
# In the case of the above example, it will execute all hooks registered
7272
# for +:active_record+ within the class +ActiveRecord::Base+.

activesupport/lib/active_support/notifications.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,8 @@ def instrument(name, payload = {})
237237
#
238238
# Raises an error if invalid event name type is passed:
239239
#
240-
# ActiveSupport::Notifications.subscribe(:render) {|*args| ...}
241-
# #=> ArgumentError (pattern must be specified as a String, Regexp or empty)
240+
# ActiveSupport::Notifications.subscribe(:render) {|*args| ...}
241+
# #=> ArgumentError (pattern must be specified as a String, Regexp or empty)
242242
#
243243
def subscribe(pattern = nil, callback = nil, &block)
244244
notifier.subscribe(pattern, callback, monotonic: false, &block)

activesupport/lib/active_support/number_helper.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -358,13 +358,14 @@ def number_to_human_size(number, options = {})
358358
# out by default (set <tt>:strip_insignificant_zeros</tt> to
359359
# +false+ to change that):
360360
#
361-
# number_to_human(12.00001) # => "12"
362-
# number_to_human(12.00001, strip_insignificant_zeros: false) # => "12.0"
361+
# number_to_human(12.00001) # => "12"
362+
# number_to_human(12.00001, strip_insignificant_zeros: false) # => "12.0"
363363
#
364364
# ==== Custom Unit Quantifiers
365365
#
366366
# You can also use your own custom unit quantifiers:
367-
# number_to_human(500000, units: { unit: 'ml', thousand: 'lt' }) # => "500 lt"
367+
#
368+
# number_to_human(500000, units: { unit: 'ml', thousand: 'lt' }) # => "500 lt"
368369
#
369370
# If in your I18n locale you have:
370371
#

0 commit comments

Comments
 (0)