Class: Array

Inherits:
Object show all
Defined in:
lib/fully_freeze/array.rb

Overview

Add fully_freeze support to the array class.

Instance Method Summary collapse

Instance Method Details

#fully_freeze(progress = {}) ⇒ Object

Do fully_freeze the array.



7
8
9
10
11
12
13
14
15
# File 'lib/fully_freeze/array.rb', line 7

def fully_freeze(progress={})
  progress[object_id] = freeze

  each do |value|
    value.fully_freeze(progress) unless progress[value.object_id]
  end

  self
end

#fully_frozen?(progress = {}) ⇒ Boolean

Is this array fully_frozen?

Returns:

  • (Boolean)


18
19
20
21
22
23
24
25
26
27
28
# File 'lib/fully_freeze/array.rb', line 18

def fully_frozen?(progress={})
  return false unless frozen?

  progress[object_id] = self

  each do |value|
    return false unless progress[value.object_id] || value.fully_frozen?(progress)
  end

  true
end