Sha256: d92081cfd967218848f6d57995d825ce0f907c3b7bb74cc439bcbc3f52e1a4d7

Contents?: true

Size: 899 Bytes

Versions: 29

Compression:

Stored size: 899 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]&.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

29 entries across 29 versions & 1 rubygems

Version Path
hyrax-2.9.6 app/strategies/hyrax/strategies/yaml_strategy.rb
hyrax-2.9.5 app/strategies/hyrax/strategies/yaml_strategy.rb
hyrax-2.9.4 app/strategies/hyrax/strategies/yaml_strategy.rb
hyrax-2.9.3 app/strategies/hyrax/strategies/yaml_strategy.rb
hyrax-2.9.2 app/strategies/hyrax/strategies/yaml_strategy.rb
hyrax-2.9.1 app/strategies/hyrax/strategies/yaml_strategy.rb
hyrax-2.9.0 app/strategies/hyrax/strategies/yaml_strategy.rb
hyrax-2.8.0 app/strategies/hyrax/strategies/yaml_strategy.rb
hyrax-2.7.2 app/strategies/hyrax/strategies/yaml_strategy.rb
hyrax-2.7.1 app/strategies/hyrax/strategies/yaml_strategy.rb
hyrax-2.7.0 app/strategies/hyrax/strategies/yaml_strategy.rb
hyrax-2.6.0 app/strategies/hyrax/strategies/yaml_strategy.rb
hyrax-3.0.0.pre.rc1 app/strategies/hyrax/strategies/yaml_strategy.rb
hyrax-3.0.0.pre.beta3 app/strategies/hyrax/strategies/yaml_strategy.rb
hyrax-2.5.1 app/strategies/hyrax/strategies/yaml_strategy.rb
hyrax-2.5.0 app/strategies/hyrax/strategies/yaml_strategy.rb
hyrax-3.0.0.pre.beta2 app/strategies/hyrax/strategies/yaml_strategy.rb
hyrax-2.4.1 app/strategies/hyrax/strategies/yaml_strategy.rb
hyrax-3.0.0.pre.beta1 app/strategies/hyrax/strategies/yaml_strategy.rb
hyrax-2.4.0 app/strategies/hyrax/strategies/yaml_strategy.rb