Class: Kharon::Processors::BooleanProcessor

Inherits:
Kharon::Processor show all
Defined in:
lib/kharon/processors/boolean_processor.rb

Overview

Processor to validate booleans. It only has the default options.

Author:

Instance Attribute Summary

Attributes inherited from Kharon::Processor

#validator

Instance Method Summary (collapse)

Methods inherited from Kharon::Processor

#initialize

Constructor Details

This class inherits a constructor from Kharon::Processor

Instance Method Details

- (Object) process(key, options = {})

Checks if the given key is a boolean or not.

Examples:

Validates a key so it has to be a boolean.

@validator.boolean(:a_boolean)

Parameters:

  • key (Object)

    the key about which verify the type.

  • options (Hash) (defaults to: {})

    a hash of options passed to this method (see documentation to know which options pass).



15
16
17
18
# File 'lib/kharon/processors/boolean_processor.rb', line 15

def process(key, options = {})
  before_all(key, options)
  match?(key, /(true)|(false)/) ? store(key, ->(item){to_boolean(item)}, options) : raise_type_error(key, "Numeric")
end