Sha256: f446f64a4c7ae92d748a7e392b6dd5476a799534715494e7a9d1d5f27ae98e9d

Contents?: true

Size: 879 Bytes

Versions: 3

Compression:

Stored size: 879 Bytes

Contents

# frozen_string_literal: true

module DevSuite
  module Utils
    module ConfigTools
      module Configuration
        # Module for global configuration
        class << self
          def included(base)
            base.extend(ClassMethods)
          end
        end

        module ClassMethods
          #
          # Provide global access to a single instance of Config
          #
          def configuration
            @configuration ||= new
          end

          #
          # Allow block-based configuration
          #
          def configure
            yield(configuration)
          rescue StandardError => e
            handle_configuration_error(e)
            raise
          end

          private

          def handle_configuration_error(error)
            puts "Configuration error: #{error.message}"
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dev_suite-0.2.3 lib/dev_suite/utils/config_tools/configuration.rb
dev_suite-0.2.2 lib/dev_suite/utils/config_tools/configuration.rb
dev_suite-0.2.1 lib/dev_suite/utils/config_tools/configuration.rb