Sha256: 5b2d45ebb5c25a85922dc9ae7d78b02b6a2a561557a1ae150262aa902b9ea009

Contents?: true

Size: 1.17 KB

Versions: 4

Compression:

Stored size: 1.17 KB

Contents

require 'elegant/configuration'

module Elegant
  # Provides methods to read and write global configuration settings.
  #
  # @example Set the author of PDF files to 'John Doe':
  #   Elegant.configure do |config|
  #     config.author = 'John Doe'
  #   end
  #
  module Config
    # Yields the global configuration to the given block.
    #
    # @example
    #   Elegant.configure do |config|
    #     config.author = 'John Doe'
    #   end
    #
    # @yield [Elegant::Configuration] The global configuration.
    def configure
      yield configuration if block_given?
    end

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

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

  extend Config
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
elegant-1.2.1 lib/elegant/config.rb
elegant-1.2.0 lib/elegant/config.rb
elegant-1.1.0 lib/elegant/config.rb
elegant-1.0.0 lib/elegant/config.rb