Class: Kharon::Processors::HashProcessor
- Inherits:
-
Kharon::Processor
- Object
- Kharon::Processor
- Kharon::Processors::HashProcessor
- Defined in:
- lib/kharon/processors/hash_processor.rb
Overview
Processor to validate hashes. It has the :has_keys and :contains options with the default ones.
Instance Attribute Summary
Attributes inherited from Kharon::Processor
Instance Method Summary (collapse)
-
- (Object) process(key, options = {})
Checks if the given key is a datetime or not.
-
- (Object) store(key, process, options)
Stores an array after verifying that it contains the values given in the contains? option.
Methods inherited from Kharon::Processor
Constructor Details
This class inherits a constructor from Kharon::Processor
Instance Method Details
- (Object) process(key, options = {})
Checks if the given key is a datetime or not.
15 16 17 18 |
# File 'lib/kharon/processors/hash_processor.rb', line 15 def process(key, = {}) before_all(key, ) is_typed?(key, Hash) ? store(key, ->(item){Hash.try_convert(item)}, ) : raise_type_error(key, "Hash") end |
- (Object) store(key, process, options)
Stores an array after verifying that it contains the values given in the contains? option.
24 25 26 27 28 |
# File 'lib/kharon/processors/hash_processor.rb', line 24 def store(key, process, ) has_keys?(key, [:has_keys]) if(.has_key?(:has_keys)) contains?(validator.filtered, validator.datas[key].values, [:contains]) if(.has_key?(:contains)) super(key, process, ) end |