Sha256: 2a077fc3855dc8421b1a02ac663c0d631221a7f3ead76b795a0778d43ebc624f

Contents?: true

Size: 850 Bytes

Versions: 1

Compression:

Stored size: 850 Bytes

Contents

# Main module of the application.
# @author Vincent Courtois <courtois.vincent@outlook.com>
module Kharon

  [:Validator, :Version, :Errors, :Handlers, :Helpers].each { |classname| autoload(classname, "kharon/#{classname.downcase}") }

  @@use_exceptions = true

  # Configuration method used to tell the module if it uses exceptions or stores error messages.
  # @param [Boolean] use TRUE if you want to use exceptions, FALSE else.
  def self.use_exceptions(use = true)
    @@use_exceptions = use
  end

  # Returns the current error handler, defined by if you use exceptions or not.
  # @return [Object] an instance of Kharon::Handlers::Exceptions if you use exceptions, an instance of Kharon::Handlers::Messages else.
  def self.errors_handler
    @@use_exceptions ? Kharon::Handlers::Exceptions.instance : Kharon::Handlers::Messages.new
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kharon-1.0.0 lib/kharon.rb