lib/oas_objs/helpers.rb in zero-rails_openapi-1.7.0 vs lib/oas_objs/helpers.rb in zero-rails_openapi-2.0.0
- old
+ new
@@ -1,5 +1,7 @@
+# frozen_string_literal: true
+
module OpenApi
module Helpers
def fusion
proc { |a, b| a.deep_merge!(b) { |common_key, va, vb| common_key == :required ? va + vb : vb } }
end
@@ -10,28 +12,10 @@
def value_present
proc { |_, v| truly_present? v }
end
- # assign.to
- def assign(value)
- @assign = value.is_a?(Symbol) ? send("_#{value}") : value
- self
- end
-
- # reducx.then_merge! => for Hash
- def reducx(*values)
- @assign = values.compact.reduce({ }, :merge!).keep_if &value_present
- self
- end
-
- def to_processed(who)
- return processed unless truly_present?(@assign)
- processed[who.to_sym] = @assign
- processed
- end
-
- def then_merge! # to_processed
- processed.tap { |it| it.merge! @assign if truly_present?(@assign) }
+ def reducing(*values)
+ values.compact.reduce(processed, :merge!).keep_if &value_present
end
end
end