Sha256: 2457c831e90e0e9855dfd4c6f6d1e3e16b636dee652916e98f397e786baec486

Contents?: true

Size: 958 Bytes

Versions: 4

Compression:

Stored size: 958 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.select { |file| file.start_with?('app/')}
      @files = @files - app_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

4 entries across 4 versions & 1 rubygems

Version Path
sugarcube-3.0.3 lib/sugarcube_pre_setup.rb
sugarcube-3.0.2 lib/sugarcube_pre_setup.rb
sugarcube-3.0.1 lib/sugarcube_pre_setup.rb
sugarcube-3.0.0 lib/sugarcube_pre_setup.rb