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-4.0.0 lib/sugarcube_pre_setup.rb
sugarcube-3.5.0 lib/sugarcube_pre_setup.rb
sugarcube-3.4.2 lib/sugarcube_pre_setup.rb
sugarcube-3.4.1 lib/sugarcube_pre_setup.rb
sugarcube-3.4.0 lib/sugarcube_pre_setup.rb
sugarcube-3.3.7 lib/sugarcube_pre_setup.rb
sugarcube-3.3.6 lib/sugarcube_pre_setup.rb
sugarcube-3.3.5 lib/sugarcube_pre_setup.rb
sugarcube-3.3.4 lib/sugarcube_pre_setup.rb
sugarcube-3.3.3 lib/sugarcube_pre_setup.rb
sugarcube-3.3.2 lib/sugarcube_pre_setup.rb
sugarcube-3.3.1 lib/sugarcube_pre_setup.rb
sugarcube-3.3.0 lib/sugarcube_pre_setup.rb
sugarcube-3.2.0 lib/sugarcube_pre_setup.rb
sugarcube-3.1.1 lib/sugarcube_pre_setup.rb
sugarcube-3.1.0 lib/sugarcube_pre_setup.rb
sugarcube-3.0.8 lib/sugarcube_pre_setup.rb
sugarcube-3.0.7 lib/sugarcube_pre_setup.rb
sugarcube-3.0.6 lib/sugarcube_pre_setup.rb
sugarcube-3.0.5 lib/sugarcube_pre_setup.rb