Sha256: eb24e2ed260736f96f966b9af71593426ade578db06f50e7d0e82d039f0ccfe9

Contents?: true

Size: 783 Bytes

Versions: 14

Compression:

Stored size: 783 Bytes

Contents

module SecureHeaders
  class XDOBuildError < StandardError; end
  class XDownloadOptions < Header
    module Constants
      XDO_HEADER_NAME = "X-Download-Options"
      DEFAULT_VALUE = 'noopen'
    end
    include Constants

    def initialize(config = nil)
      @config = config
      validate_config unless @config.nil?
    end

    def name
      XDO_HEADER_NAME
    end

    def value
      case @config
      when NilClass
        DEFAULT_VALUE
      when String
        @config
      else
        @config[:value]
      end
    end

    private

    def validate_config
      value = @config.is_a?(Hash) ? @config[:value] : @config
      unless value.casecmp(DEFAULT_VALUE) == 0
        raise XDOBuildError.new("Value can only be nil or 'noopen'")
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
secure_headers-2.2.4 lib/secure_headers/headers/x_download_options.rb
secure_headers-2.2.3 lib/secure_headers/headers/x_download_options.rb
secure_headers-2.2.2 lib/secure_headers/headers/x_download_options.rb
secure_headers-2.2.1 lib/secure_headers/headers/x_download_options.rb
secure_headers-2.2.0 lib/secure_headers/headers/x_download_options.rb
secure_headers-2.1.0 lib/secure_headers/headers/x_download_options.rb
secure_headers-2.0.2 lib/secure_headers/headers/x_download_options.rb
secure_headers-2.0.1 lib/secure_headers/headers/x_download_options.rb
secure_headers-2.0.0 lib/secure_headers/headers/x_download_options.rb
secure_headers-1.4.1 lib/secure_headers/headers/x_download_options.rb
secure_headers-1.4.0 lib/secure_headers/headers/x_download_options.rb
secure_headers-2.0.0.pre2 lib/secure_headers/headers/x_download_options.rb
secure_headers-2.0.0.pre lib/secure_headers/headers/x_download_options.rb
secure_headers-1.3.4 lib/secure_headers/headers/x_download_options.rb