Module: Praxis::Finalizable

Included in:
Blueprint, Mapper::Resource
Defined in:
lib/praxis/finalizable.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(klass) ⇒ Object



5
6
7
8
9
# File 'lib/praxis/finalizable.rb', line 5

def self.extended(klass)
  klass.module_eval do
    @finalizable = Set.new
  end
end

Instance Method Details

#_finalize!Object



25
26
27
# File 'lib/praxis/finalizable.rb', line 25

def _finalize!
  @finalized = true
end

#finalizableObject



17
18
19
# File 'lib/praxis/finalizable.rb', line 17

def finalizable
  @finalizable
end

#finalize!Object



29
30
31
32
33
# File 'lib/praxis/finalizable.rb', line 29

def finalize!
  finalizable.reject(&:finalized?).each(&:_finalize!)

  finalize! unless finalizable.all?(&:finalized?)
end

#finalized?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/praxis/finalizable.rb', line 21

def finalized?
  @finalized
end

#inherited(base) ⇒ Object



11
12
13
14
15
# File 'lib/praxis/finalizable.rb', line 11

def inherited(base)
  @finalizable << base
  base.instance_variable_set(:@finalizable, @finalizable)
  base.instance_variable_set(:@finalized, false)
end