phlex 1.9.2 → 1.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of phlex might be problematic. Click here for more details.

data/lib/phlex/helpers.rb CHANGED
@@ -1,8 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("3.0")
4
- using Phlex::Overrides::Symbol::Name
5
- end
3
+ require "set"
6
4
 
7
5
  module Phlex::Helpers
8
6
  private
@@ -76,13 +74,31 @@ module Phlex::Helpers
76
74
  def mix(*args)
77
75
  args.each_with_object({}) do |object, result|
78
76
  result.merge!(object) do |_key, old, new|
77
+ next new if old.nil?
78
+
79
79
  case new
80
80
  when Hash
81
81
  old.is_a?(Hash) ? mix(old, new) : new
82
82
  when Array
83
- old.is_a?(Array) ? (old + new) : new
83
+ case old
84
+ when Array then old + new
85
+ when Set then old.to_a + new
86
+ when Hash then new
87
+ else
88
+ [old] + new
89
+ end
90
+ when Set
91
+ case old
92
+ when Set then old + new
93
+ when Array then old + new.to_a
94
+ when Hash then new
95
+ else
96
+ new + [old]
97
+ end
84
98
  when String
85
- old.is_a?(String) ? "#{old} #{new}" : new
99
+ old.is_a?(String) ? "#{old} #{new}" : old + old.class[new]
100
+ when nil
101
+ old
86
102
  else
87
103
  new
88
104
  end