Module: Kharon

Defined in:
lib/kharon.rb,
lib/kharon/errors.rb,
lib/kharon/version.rb,
lib/kharon/validate.rb,
lib/kharon/handlers.rb,
lib/kharon/processor.rb,
lib/kharon/validator.rb,
lib/kharon/processors.rb,
lib/kharon/handlers/messages.rb,
lib/kharon/errors/validation.rb,
lib/kharon/handlers/exceptions.rb,
lib/kharon/processors/box_processor.rb,
lib/kharon/processors/ssid_processor.rb,
lib/kharon/processors/date_processor.rb,
lib/kharon/processors/text_processor.rb,
lib/kharon/processors/hash_processor.rb,
lib/kharon/processors/email_processor.rb,
lib/kharon/processors/array_processor.rb,
lib/kharon/processors/boolean_processor.rb,
lib/kharon/processors/integer_processor.rb,
lib/kharon/processors/numeric_processor.rb,
lib/kharon/processors/datetime_processor.rb

Overview

Main module of the application.

Author:

Defined Under Namespace

Modules: Errors, Handlers, Processors, Validate Classes: Processor, Validator

Constant Summary

VERSION =

Current version of the application.

"1.1.0"
@@use_exceptions =
true
@@processors =
{}

Class Method Summary (collapse)

Class Method Details

+ (Object) add_processor(name, classname)

Adds a processor class to the list of processors.

Parameters:

  • name (Symbol)

    the name of the stored processor to retrieve it after. It will be the method you call to process a data with that processor.

  • classname (Class)

    the class object for the processor to be instanciated later.



24
25
26
# File 'lib/kharon.rb', line 24

def self.add_processor(name, classname)
  @@processors[name] = classname if classname.ancestors.include? Kharon::Processor
end

+ (Object) errors_handler

Returns the current error handler, defined by if you use exceptions or not.

Returns:

  • (Object)

    an instance of Kharon::Handlers::Exceptions if you use exceptions, an instance of Kharon::Handlers::Messages else.



17
18
19
# File 'lib/kharon.rb', line 17

def self.errors_handler
  @@use_exceptions ? Kharon::Handlers::Exceptions.instance : Kharon::Handlers::Messages.new
end

+ (Boolean) has_processor?(name)

Checks if a processor currently exists in the system.

Parameters:

  • name (String)

    the name of the processor to check the existence.

Returns:

  • (Boolean)

    TRUE if the processor exists, FALSE if not.



43
44
45
# File 'lib/kharon.rb', line 43

def self.has_processor?(name)
  @@processors.keys.include?(name)
end

+ (Hash) processors

Getter for the list of processors.

Returns:

  • (Hash)

    the list of processors currently available.



36
37
38
# File 'lib/kharon.rb', line 36

def self.processors
  @@processors
end

+ (Object) remove_processor(name)

Removes a processor from the list of available processors.

Parameters:

  • name (Symbol)

    the name (key) of the processor to delete.



30
31
32
# File 'lib/kharon.rb', line 30

def self.remove_processor(name)
  @@processors.delete(name) if self.has_processor?(name)
end

+ (Object) use_exceptions(use = true)

Configuration method used to tell the module if it uses exceptions or stores error messages.

Parameters:

  • use (Boolean) (defaults to: true)

    TRUE if you want to use exceptions, FALSE else.



11
12
13
# File 'lib/kharon.rb', line 11

def self.use_exceptions(use = true)
  @@use_exceptions = use
end