Sha256: 40e2864ba17d6af5bf7b8650305a9899ff12ff6f9b703c599abb27fe724eeda5

Contents?: true

Size: 640 Bytes

Versions: 12

Compression:

Stored size: 640 Bytes

Contents

# frozen_string_literal: true
module Praxis
  module Finalizable
    def self.extended(klass)
      klass.module_eval do
        @finalizable = Set.new
      end
    end

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

    def finalizable
      @finalizable
    end

    def finalized?
      @finalized
    end

    def _finalize!
      @finalized = true
    end

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

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

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
praxis-2.0.pre.18 lib/praxis/finalizable.rb
praxis-2.0.pre.17 lib/praxis/finalizable.rb
praxis-2.0.pre.16 lib/praxis/finalizable.rb
praxis-2.0.pre.15 lib/praxis/finalizable.rb
praxis-2.0.pre.14 lib/praxis/finalizable.rb
praxis-2.0.pre.13 lib/praxis/finalizable.rb
praxis-2.0.pre.12 lib/praxis/finalizable.rb
praxis-2.0.pre.11 lib/praxis/finalizable.rb
praxis-2.0.pre.10 lib/praxis/finalizable.rb
praxis-blueprints-3.5 lib/praxis-blueprints/finalizable.rb
praxis-blueprints-3.4 lib/praxis-blueprints/finalizable.rb
praxis-blueprints-3.3 lib/praxis-blueprints/finalizable.rb