Sha256: 3c95a652463cd7aee636db7f11a299d27f8f8fb7aa0caf5a5a67f64f541f61ad

Contents?: true

Size: 669 Bytes

Versions: 14

Compression:

Stored size: 669 Bytes

Contents

module Praxis::Mapper
  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! 
      self.finalizable.reject(&:finalized?).each do |klass|
        klass._finalize!
      end

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

  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
praxis-mapper-4.5 lib/praxis-mapper/finalizable.rb
praxis-mapper-4.4.1 lib/praxis-mapper/finalizable.rb
praxis-mapper-4.4 lib/praxis-mapper/finalizable.rb
praxis-mapper-4.3 lib/praxis-mapper/finalizable.rb
praxis-mapper-4.2 lib/praxis-mapper/finalizable.rb
praxis-mapper-4.1.2 lib/praxis-mapper/finalizable.rb
praxis-mapper-4.1.1 lib/praxis-mapper/finalizable.rb
praxis-mapper-4.1 lib/praxis-mapper/finalizable.rb
praxis-mapper-4.0 lib/praxis-mapper/finalizable.rb
praxis-mapper-3.4.0 lib/praxis-mapper/finalizable.rb
praxis-mapper-3.3 lib/praxis-mapper/finalizable.rb
praxis-mapper-3.2 lib/praxis-mapper/finalizable.rb
praxis-mapper-3.1.2 lib/praxis-mapper/finalizable.rb
praxis-mapper-3.1.1 lib/praxis-mapper/finalizable.rb