Sha256: 5350bd5eacbdc2f0522c7a74ec8a6e30baa1a33a04c8cc24fc09f83e26782b71
Contents?: true
Size: 944 Bytes
Versions: 5
Compression:
Stored size: 944 Bytes
Contents
# frozen_string_literal: true require "store_model/combine_errors_strategies/mark_invalid_error_strategy" require "store_model/combine_errors_strategies/merge_error_strategy" module StoreModel # Module with built-in strategies for combining errors. module CombineErrorsStrategies module_function # Finds a strategy based on +options+ and global config. # # @param options [Hash] # # @return [Object] strategy def configure(options) configured_strategy = options[:merge_errors] || StoreModel.config.merge_errors if configured_strategy.respond_to?(:call) configured_strategy elsif configured_strategy == true StoreModel::CombineErrorsStrategies::MergeErrorStrategy.new elsif configured_strategy.nil? StoreModel::CombineErrorsStrategies::MarkInvalidErrorStrategy.new else const_get(configured_strategy.to_s.camelize).new end end end end
Version data entries
5 entries across 5 versions & 1 rubygems