lib/oas_objs/helpers.rb in zero-rails_openapi-1.4.2 vs lib/oas_objs/helpers.rb in zero-rails_openapi-1.4.3

- old
+ new

@@ -1,7 +1,23 @@ module OpenApi module Helpers + def fusion + proc { |a, b| a.merge!(b, &_fusion) } + end + + def _fusion + proc do |_common_key, x, y| + if x.is_a?(Hash) && y.is_a?(Hash) + x.merge(y, &_fusion) + elsif x.is_a?(Array) && y.is_a?(Array) + x.concat(y) + else + y + end + end + end + def truly_present?(obj) obj == false || obj.present? end def value_present @@ -12,10 +28,10 @@ def assign(value) @assign = value.is_a?(Symbol) ? send("_#{value}") : value self end - # reduceee.then_merge! => for Hash + # reducx.then_merge! => for Hash def reducx(*values) @assign = values.compact.reduce({ }, :merge).keep_if &value_present self end