From 71c67d1fd863bfa8fa820e4dc6e1d158586d6d4b Mon Sep 17 00:00:00 2001 From: AvnerCohen Date: Sat, 20 Oct 2012 16:54:43 +0200 Subject: [PATCH] Hash Syntax changes to 1.9 format --- activesupport/lib/active_support/core_ext/array/wrap.rb | 2 +- .../lib/active_support/core_ext/hash/conversions.rb | 2 +- activesupport/lib/active_support/core_ext/hash/slice.rb | 4 ++-- .../lib/active_support/core_ext/module/deprecation.rb | 8 ++++---- .../lib/active_support/core_ext/time/calculations.rb | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/activesupport/lib/active_support/core_ext/array/wrap.rb b/activesupport/lib/active_support/core_ext/array/wrap.rb index 7bf28b2f27..ffaf6ef024 100644 --- a/activesupport/lib/active_support/core_ext/array/wrap.rb +++ b/activesupport/lib/active_support/core_ext/array/wrap.rb @@ -23,7 +23,7 @@ class Array # The last point is particularly worth comparing for some enumerables: # # Array(foo: :bar) # => [[:foo, :bar]] - # Array.wrap(foo: :bar) # => [{:foo => :bar}] + # Array.wrap(foo: :bar) # => [{foo: :bar}] # # There's also a related idiom that uses the splat operator: # diff --git a/activesupport/lib/active_support/core_ext/hash/conversions.rb b/activesupport/lib/active_support/core_ext/hash/conversions.rb index 828f03ad62..f5e3a9b842 100644 --- a/activesupport/lib/active_support/core_ext/hash/conversions.rb +++ b/activesupport/lib/active_support/core_ext/hash/conversions.rb @@ -131,7 +131,7 @@ def typecast_xml_value(value) else xml_value = Hash[value.map { |k,v| [k, typecast_xml_value(v)] }] - # Turn { :files => { :file => # } } into { :files => # } so it is compatible with + # Turn { files: { file: # } } into { files: # } so it is compatible with # how multipart uploaded files from HTML appear xml_value['file'].is_a?(StringIO) ? xml_value['file'] : xml_value end diff --git a/activesupport/lib/active_support/core_ext/hash/slice.rb b/activesupport/lib/active_support/core_ext/hash/slice.rb index 45fec57009..36d5a4d0f2 100644 --- a/activesupport/lib/active_support/core_ext/hash/slice.rb +++ b/activesupport/lib/active_support/core_ext/hash/slice.rb @@ -21,7 +21,7 @@ def slice(*keys) # Returns a hash containing the removed key/value pairs. # # { a: 1, b: 2, c: 3, d: 4 }.slice!(:a, :b) - # # => {:c => 3, :d => 4} + # # => {c: 3, d: 4} def slice!(*keys) keys.map! { |key| convert_key(key) } if respond_to?(:convert_key, true) omit = slice(*self.keys - keys) @@ -33,7 +33,7 @@ def slice!(*keys) # Removes and returns the key/value pairs matching the given keys. # # { a: 1, b: 2, c: 3, d: 4 }.extract!(:a, :b) - # # => {:a => 1, :b => 2} + # # => {a: 1, b: 2} def extract!(*keys) keys.each_with_object({}) { |key, result| result[key] = delete(key) } end diff --git a/activesupport/lib/active_support/core_ext/module/deprecation.rb b/activesupport/lib/active_support/core_ext/module/deprecation.rb index 34ec6a3d8f..cc45cee5b8 100644 --- a/activesupport/lib/active_support/core_ext/module/deprecation.rb +++ b/activesupport/lib/active_support/core_ext/module/deprecation.rb @@ -2,13 +2,13 @@ class Module # deprecate :foo - # deprecate :bar => 'message' - # deprecate :foo, :bar, :baz => 'warning!', :qux => 'gone!' + # deprecate bar: 'message' + # deprecate :foo, :bar, baz: 'warning!', qux: 'gone!' # # You can also use custom deprecator instance: # - # deprecate :foo, :deprecator => MyLib::Deprecator.new - # deprecate :foo, :bar => "warning!", :deprecator => MyLib::Deprecator.new + # deprecate :foo, deprecator: MyLib::Deprecator.new + # deprecate :foo, bar: "warning!", deprecator: MyLib::Deprecator.new # # \Custom deprecators must respond to deprecation_warning(deprecated_method_name, message, caller_backtrace) # method where you can implement your custom warning behavior. diff --git a/activesupport/lib/active_support/core_ext/time/calculations.rb b/activesupport/lib/active_support/core_ext/time/calculations.rb index e3665cd896..931851d40e 100644 --- a/activesupport/lib/active_support/core_ext/time/calculations.rb +++ b/activesupport/lib/active_support/core_ext/time/calculations.rb @@ -135,7 +135,7 @@ def since(seconds) # Returns a new Time representing the start of the day (0:00) def beginning_of_day - #(self - seconds_since_midnight).change(:usec => 0) + #(self - seconds_since_midnight).change(usec: 0) change(:hour => 0) end alias :midnight :beginning_of_day -- GitLab