Sha256: 55b4adfc6be1829c3c66299a4e6dcbe7e7c3316c3d1b72c7d75d8b3dfeebc6e1

Contents?: true

Size: 985 Bytes

Versions: 1

Compression:

Stored size: 985 Bytes

Contents

require "active_support/core_ext/numeric/time"
require "socrates/logger"
require "socrates/storage/memory"

module Socrates
  def self.config
    @config ||= Configuration.new
  end

  def self.configure
    yield(config)
  end

  class Configuration
    attr_accessor :view_path
    attr_accessor :storage
    attr_accessor :error_message
    attr_accessor :expired_timeout # seconds
    attr_accessor :logger
    attr_accessor :error_handler   # a callable like ->(String, Exception) { ... }
    attr_accessor :warn_handler    # a callable like ->(String) { ... }

    def initialize
      @storage         = Storage::Memory.new
      @error_message   = "Sorry, something went wrong. We'll have to start over..."
      @expired_timeout = 30.minutes
      @logger          = Socrates::Logger.default
      @error_handler   = proc { |_message, _error| } # rubocop:disable Lint/EmptyBlock
      @warn_handler    = proc { |_message| } # rubocop:disable Lint/EmptyBlock
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
socrates-0.1.26 lib/socrates/configuration.rb