Module: Nanoc::Core::CoreExt::ArrayExtensions

Included in:
Array
Defined in:
lib/nanoc/core/core_ext/array.rb

Instance Method Summary collapse

Instance Method Details

#__nanoc_freeze_recursivelyvoid

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 #__nanoc_freeze_recursively if they respond to that message, or #freeze if they do not.

See Also:

  • Hash#__nanoc_freeze_recursively


35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/nanoc/core/core_ext/array.rb', line 35

def __nanoc_freeze_recursively
  return if frozen?

  freeze
  each do |value|
    if value.respond_to?(:__nanoc_freeze_recursively)
      value.__nanoc_freeze_recursively
    else
      value.freeze
    end
  end
end

#__nanoc_stringify_keys_recursivelyObject



20
21
22
23
24
25
26
# File 'lib/nanoc/core/core_ext/array.rb', line 20

def __nanoc_stringify_keys_recursively
  array = []
  each do |element|
    array << (element.respond_to?(:__nanoc_stringify_keys_recursively) ? element.__nanoc_stringify_keys_recursively : element)
  end
  array
end

#__nanoc_symbolize_keys_recursivelyArray

Returns a new array where all items’ keys are recursively converted to symbols by calling ArrayExtensions#__nanoc_symbolize_keys_recursively or HashExtensions#__nanoc_symbolize_keys_recursively.

Returns:

  • (Array)

    The converted array



12
13
14
15
16
17
18
# File 'lib/nanoc/core/core_ext/array.rb', line 12

def __nanoc_symbolize_keys_recursively
  array = []
  each do |element|
    array << (element.respond_to?(:__nanoc_symbolize_keys_recursively) ? element.__nanoc_symbolize_keys_recursively : element)
  end
  array
end