Sha256: df55a5249889855a20eb07f9b3caa1716a6cb70d9c3bc24a8e32619c45f0a7f5

Contents?: true

Size: 816 Bytes

Versions: 9

Compression:

Stored size: 816 Bytes

Contents

# frozen_string_literal: true

require 'tqdm'

module Monarchy
  class << self
    def rebuild!
      p 'Rebuilding Monarchy...'
      hierarhization
      reparentize
      p 'Rebuilding Monarchy ended!'
    end

    private

    def hierarhization
      p 'Monarchy hierarchization...'
      Monarchy.resource_classes.with_progress.each do |klass|
        klass.all.each do |model|
          model.send(:ensure_hierarchy, true)
        end
      end
      p 'Monarchy hierarchization ended!'
    end

    def reparentize
      p 'Monarchy reparentize...'

      Monarchy.resource_classes.with_progress.each do |klass|
        klass.all.each do |model|
          model.send(:assign_parent, true)
        end
      end

      Monarchy.hierarchy_class.rebuild!
      p 'Monarchy reparentize ended!'
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
monarchy-2.7.0 lib/monarchy/tasks.rb
monarchy-2.6.1 lib/monarchy/tasks.rb
monarchy-2.6.0 lib/monarchy/tasks.rb
monarchy-2.5.0 lib/monarchy/tasks.rb
monarchy-2.4.0 lib/monarchy/tasks.rb
monarchy-2.3.0 lib/monarchy/tasks.rb
monarchy-2.2.2 lib/monarchy/tasks.rb
monarchy-2.2.1 lib/monarchy/tasks.rb
monarchy-2.2.0 lib/monarchy/tasks.rb