Sha256: 70b127d1d34692348c2481b0548556104cfc39a4aa488f330b91eac24116ee34

Contents?: true

Size: 925 Bytes

Versions: 28

Compression:

Stored size: 925 Bytes

Contents

module Hyrax::Strategies
  class YamlStrategy < Flipflop::Strategies::AbstractStrategy
    class << self
      def default_description
        "Features configured by a YAML configuration file."
      end
    end

    def initialize(**options)
      @config_file = options.delete(:config)
      yaml_file
      super(**options)
    end

    def switchable?
      false
    end

    def enabled?(feature)
      return unless key_exists?(feature)
      yaml_file[feature.to_s]["enabled"]
    end

    def switch!(_feature, _enabled); end

    def clear!(_feature); end

    private

      def key_exists?(feature)
        yaml_file[feature.to_s] && yaml_file[feature.to_s].key?("enabled")
      end

      def yaml_file
        @yaml_file ||=
          begin
            if File.exist?(@config_file)
              YAML.load_file(@config_file)
            else
              {}
            end
          end
      end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
hyrax-1.1.1 app/strategies/hyrax/strategies/yaml_strategy.rb
hyrax-2.0.3 app/strategies/hyrax/strategies/yaml_strategy.rb
hyrax-2.1.0 app/strategies/hyrax/strategies/yaml_strategy.rb
hyrax-2.1.0.rc4 app/strategies/hyrax/strategies/yaml_strategy.rb
hyrax-2.1.0.rc3 app/strategies/hyrax/strategies/yaml_strategy.rb
hyrax-2.1.0.rc2 app/strategies/hyrax/strategies/yaml_strategy.rb
hyrax-2.1.0.rc1 app/strategies/hyrax/strategies/yaml_strategy.rb
hyrax-1.1.0 app/strategies/hyrax/strategies/yaml_strategy.rb
hyrax-2.1.0.beta2 app/strategies/hyrax/strategies/yaml_strategy.rb
hyrax-2.0.2 app/strategies/hyrax/strategies/yaml_strategy.rb
hyrax-2.1.0.beta1 app/strategies/hyrax/strategies/yaml_strategy.rb
hyrax-2.0.1 app/strategies/hyrax/strategies/yaml_strategy.rb
hyrax-2.0.0 app/strategies/hyrax/strategies/yaml_strategy.rb
hyrax-2.0.0.rc3 app/strategies/hyrax/strategies/yaml_strategy.rb
hyrax-2.0.0.rc2 app/strategies/hyrax/strategies/yaml_strategy.rb
hyrax-2.0.0.rc1 app/strategies/hyrax/strategies/yaml_strategy.rb
hyrax-1.0.5 app/strategies/hyrax/strategies/yaml_strategy.rb
hyrax-2.0.0.beta5 app/strategies/hyrax/strategies/yaml_strategy.rb
hyrax-2.0.0.beta4 app/strategies/hyrax/strategies/yaml_strategy.rb
hyrax-2.0.0.beta3 app/strategies/hyrax/strategies/yaml_strategy.rb