Module: Nanoc::ArrayExtensions
- Included in:
- Array
- Defined in:
- lib/nanoc/base/core_ext/array.rb
Instance Method Summary (collapse)
-
- (String) checksum
private
Calculates the checksum for this array.
-
- (void) freeze_recursively
Freezes the contents of the array, as well as all array elements.
-
- (Object) stringify_keys
deprecated
Deprecated.
Renamed to #stringify_keys_recursively
-
- (Array) stringify_keys_recursively
Returns a new array where all items’ keys are recursively converted to strings by calling #stringify_keys_recursively or HashExtensions#stringify_keys_recursively.
-
- (Object) symbolize_keys
deprecated
Deprecated.
Renamed to #symbolize_keys_recursively
-
- (Array) symbolize_keys_recursively
Returns a new array where all items’ keys are recursively converted to symbols by calling #symbolize_keys_recursively or HashExtensions#symbolize_keys_recursively.
Instance Method Details
- (String) checksum
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Calculates the checksum for this array. Any change to this array will result in a different checksum.
66 67 68 |
# File 'lib/nanoc/base/core_ext/array.rb', line 66 def checksum Nanoc::Checksummer.calc(self) end |
- (void) freeze_recursively
This method returns an undefined value.
Freezes the contents of the array, as well as all array elements. The array elements will be frozen using #freeze_recursively if they respond to that message, or #freeze if they do not.
48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/nanoc/base/core_ext/array.rb', line 48 def freeze_recursively return if self.frozen? freeze each do |value| if value.respond_to?(:freeze_recursively) value.freeze_recursively else value.freeze end end end |
- (Object) stringify_keys
Renamed to #stringify_keys_recursively
35 36 37 |
# File 'lib/nanoc/base/core_ext/array.rb', line 35 def stringify_keys stringify_keys_recursively end |
- (Array) stringify_keys_recursively
Returns a new array where all items’ keys are recursively converted to strings by calling #stringify_keys_recursively or HashExtensions#stringify_keys_recursively.
28 29 30 31 32 |
# File 'lib/nanoc/base/core_ext/array.rb', line 28 def stringify_keys_recursively reduce([]) do |array, element| array + [ element.respond_to?(:stringify_keys_recursively) ? element.stringify_keys_recursively : element ] end end |
- (Object) symbolize_keys
Renamed to #symbolize_keys_recursively
19 20 21 |
# File 'lib/nanoc/base/core_ext/array.rb', line 19 def symbolize_keys symbolize_keys_recursively end |
- (Array) symbolize_keys_recursively
Returns a new array where all items’ keys are recursively converted to symbols by calling #symbolize_keys_recursively or HashExtensions#symbolize_keys_recursively.
10 11 12 13 14 15 16 |
# File 'lib/nanoc/base/core_ext/array.rb', line 10 def symbolize_keys_recursively array = [] each do |element| array << (element.respond_to?(:symbolize_keys_recursively) ? element.symbolize_keys_recursively : element) end array end |