Module: ActiveStorageValidations::OptionProcUnfolding
- Included in:
- AspectRatioValidator, ContentTypeValidator, DimensionValidator, LimitValidator, ProcessableImageValidator, SizeValidator
- Defined in:
- lib/active_storage_validations/option_proc_unfolding.rb
Instance Method Summary collapse
Instance Method Details
#unfold_procs(record, object, only_keys) ⇒ Object
4 5 6 7 8 9 10 11 12 13 |
# File 'lib/active_storage_validations/option_proc_unfolding.rb', line 4 def unfold_procs(record, object, only_keys) case object when Hash object.merge(object) { |key, value| only_keys&.exclude?(key) ? {} : unfold_procs(record, value, nil) } when Array object.map { |o| unfold_procs(record, o, only_keys) } else object.is_a?(Proc) ? object.call(record) : object end end |