Skip to content

Commit

Permalink
Use ArrayWrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
ankane committed Dec 31, 2024
1 parent a09c2a0 commit b5cda79
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/neighbor/postgresql.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,12 @@ def initialize_type_map(m = type_map)
end
end

ArrayWrapper = Struct.new(:to_a)

module ArrayMethods
def type_cast_array(value, method)
if (subtype.is_a?(Neighbor::Type::Vector) || subtype.is_a?(Neighbor::Type::Halfvec)) && method != :deserialize && value.is_a?(::Array) && value.all? { |v| v.is_a?(::Numeric) }
@subtype.public_send(method, value)
super(ArrayWrapper.new(value), method)
else
super
end
Expand Down

0 comments on commit b5cda79

Please sign in to comment.