Sha256: 432efb0ff073a02d1efe22b8ce10893191f4ad77f39656f92015d87ad08b5727

Contents?: true

Size: 773 Bytes

Versions: 8

Compression:

Stored size: 773 Bytes

Contents

module Flipflop
  class FeatureLoader
    @@lock = Monitor.new

    class << self
      def current
        @current or @@lock.synchronize { @current ||= new }
      end

      private :new
    end

    extend Forwardable
    delegate [:execute, :updated?] => :checker

    def initialize
      @paths = []
    end

    def append(engine)
      @paths.concat(engine.paths.add("config/features.rb".freeze).existent)
    end

    private

    def checker
      @checker or @@lock.synchronize do
        @checker ||= ActiveSupport::FileUpdateChecker.new(@paths) { reload! }
      end
    end

    def reload!
      @@lock.synchronize do
        Flipflop::FeatureSet.current.replace do
          @paths.each { |path| Kernel.load(path) }
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
flipflop-2.8.0 lib/flipflop/feature_loader.rb
flipflop-2.7.1 lib/flipflop/feature_loader.rb
flipflop-2.7.0 lib/flipflop/feature_loader.rb
flipflop-2.6.0 lib/flipflop/feature_loader.rb
flipflop-2.5.0 lib/flipflop/feature_loader.rb
flipflop-2.4.0 lib/flipflop/feature_loader.rb
flipflop-2.3.1 lib/flipflop/feature_loader.rb
flipflop-2.3.0 lib/flipflop/feature_loader.rb