Module: StoreModel::CombineErrorsStrategies
- Defined in:
- lib/store_model/combine_errors_strategies.rb,
lib/store_model/combine_errors_strategies/merge_error_strategy.rb,
lib/store_model/combine_errors_strategies/merge_array_error_strategy.rb,
lib/store_model/combine_errors_strategies/mark_invalid_error_strategy.rb
Overview
Module with built-in strategies for combining errors.
Defined Under Namespace
Classes: MarkInvalidErrorStrategy, MergeArrayErrorStrategy, MergeErrorStrategy
Class Method Summary collapse
-
.configure(options) ⇒ Object
Finds a strategy based on
options
and global config. -
.configure_array(options) ⇒ Object
Finds a array strategy based on
options
and global config. - .get_configured_strategy(configured_strategy, true_strategy_class) ⇒ Object
Class Method Details
.configure(options) ⇒ Object
Finds a strategy based on options
and global config.
17 18 19 20 21 22 23 24 |
# File 'lib/store_model/combine_errors_strategies.rb', line 17 def configure() configured_strategy = [:merge_errors] || StoreModel.config.merge_errors get_configured_strategy( configured_strategy, StoreModel::CombineErrorsStrategies::MergeErrorStrategy ) end |
.configure_array(options) ⇒ Object
Finds a array strategy based on options
and global config.
31 32 33 34 35 36 37 38 |
# File 'lib/store_model/combine_errors_strategies.rb', line 31 def configure_array() configured_strategy = [:merge_array_errors] || StoreModel.config.merge_array_errors get_configured_strategy( configured_strategy, StoreModel::CombineErrorsStrategies::MergeArrayErrorStrategy ) end |
.get_configured_strategy(configured_strategy, true_strategy_class) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/store_model/combine_errors_strategies.rb', line 40 def get_configured_strategy(configured_strategy, true_strategy_class) if configured_strategy.respond_to?(:call) configured_strategy elsif configured_strategy == true true_strategy_class.new elsif configured_strategy.nil? StoreModel::CombineErrorsStrategies::MarkInvalidErrorStrategy.new else const_get(configured_strategy.to_s.camelize).new end end |