Sha256: bc834081ad100329ac15bd044feb11bd20ee9b32e532de3eb2e7dc310e94ae49

Contents?: true

Size: 901 Bytes

Versions: 21

Compression:

Stored size: 901 Bytes

Contents

module Motion module Project
  class App
    class << self
      def pre_setup(&block)
        config_without_setup.pre_setup_blocks << block
      end
      def post_setup(&block)
        config_without_setup.post_setup_blocks << block
      end
    end
  end
end end

module Motion; module Project
  class Config

    def pre_setup_blocks
      @pre_setup_blocks ||= []
    end

    def post_setup_blocks
      @post_setup_blocks ||= []
    end

    alias sugarcube_old_setup setup
    def setup
      app_files = @files.flatten

      @files = []
      if @pre_setup_blocks
        @pre_setup_blocks.each { |b| b.call(self) }
        @pre_setup_blocks = nil
      end
      @files.concat(app_files)

      sugarcube_old_setup.tap do
        if @post_setup_blocks
          @post_setup_blocks.each { |b| b.call(self) }
          @post_setup_blocks = nil
        end
      end
    end
  end
end end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
sugarcube-3.0.4 lib/sugarcube_pre_setup.rb