Sha256: da0603a2ec78e03f9af4168e84fdc973c1a8ae14d52ffa0c65f44e349fbbf806

Contents?: true

Size: 823 Bytes

Versions: 1

Compression:

Stored size: 823 Bytes

Contents

module Fortress
  class << self
    attr_accessor :configuration
  end

  def self.configure
    self.configuration ||= Configuration.new

    yield(configuration)

    apply_configuration!
  end

  class Configuration
    attr_reader :options

    def externals=(value)
      return unless value

      @options = { externals: externals_from(value) }
    end

    private

    def externals_from(value)
      case
      when value.is_a?(String) then [value]
      when value.is_a?(Array) then value
      end
    end
  end

  private

  def self.apply_configuration!
    if configuration.options.try(:key?, :externals)
      fortress_allow_externals!(configuration.options[:externals])
    end
  end

  def self.fortress_allow_externals!(externals)
    externals.each { |name| Mechanism.authorise!(name, :all) }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fortress-0.2.0 lib/fortress/configuration.rb