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.
65 66 67 |
# File 'lib/nanoc/base/core_ext/array.rb', line 65 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.
47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/nanoc/base/core_ext/array.rb', line 47 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
34 35 36 |
# File 'lib/nanoc/base/core_ext/array.rb', line 34 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.
27 28 29 30 31 |
# File 'lib/nanoc/base/core_ext/array.rb', line 27 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
18 19 20 |
# File 'lib/nanoc/base/core_ext/array.rb', line 18 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.
9 10 11 12 13 14 15 |
# File 'lib/nanoc/base/core_ext/array.rb', line 9 def symbolize_keys_recursively array = [] each do |element| array << (element.respond_to?(:symbolize_keys_recursively) ? element.symbolize_keys_recursively : element) end array end |