Sha256: 8f6ebea260b8daa9c1c6ddfd8e4b30512572de758ae264e440207bcf2a4e8842

Contents?: true

Size: 1.44 KB

Versions: 4

Compression:

Stored size: 1.44 KB

Contents

require 'star/configuration'

module Star
  # Provides methods to read and write global configuration settings.
  #
  # @example Set the API key for a server-only YouTube app:
  #   Star.configure do |config|
  #     config.access_key_id = 'ABCDEFGHIJ1234567890'
  #   end
  #
  # Note that Star.configure has precedence over values through with
  # environment variables (see {Star::Configuration}).
  #
  module Config
    # Yields the global configuration to the given block.
    #
    # @example
    #   Star.configure do |config|
    #     config.access_key_id = 'ABCDEFGHIJ1234567890'
    #   end
    #
    # @yield [Star::Configuration] The global configuration.
    def configure
      yield configuration if block_given?
    end

    # @return [Boolean] whether files are stored remotely (on S3).
    def remote?
      !!configuration.remote
    end

    # Returns the global {Star::Models::Configuration} object.
    #
    # While this method _can_ be used to read and write configuration settings,
    # it is easier to use {Star::Config#configure} Star.configure}.
    #
    # @example
    #     Star.configuration.access_key_id = 'ABCDEFGHIJ1234567890'
    #
    # @return [Star::Configuration] The global configuration.
    def configuration
      @configuration ||= Star::Configuration.new
    end
  end

  # @note Config is the only module auto-loaded in the Star module,
  #       in order to have a syntax as easy as Star.configure

  extend Config
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
star-1.3.0 lib/star/config.rb
star-1.2.0 lib/star/config.rb
star-1.1.0 lib/star/config.rb
star-1.0.0 lib/star/config.rb