lib/sequel/plugins/validation_helpers.rb in sequel-4.21.0 vs lib/sequel/plugins/validation_helpers.rb in sequel-4.22.0
- old
+ new
@@ -154,11 +154,11 @@
# that the column value is an instance of the expected class based on
# the column's schema type.
def validates_schema_types(atts=keys, opts=OPTS)
Array(atts).each do |k|
if type = schema_type_class(k)
- validates_type(type, k, {:allow_nil=>true}.merge(opts))
+ validates_type(type, k, {:allow_nil=>true}.merge!(opts))
end
end
end
# Check if value is an instance of a class. If +klass+ is an array,
@@ -222,11 +222,11 @@
# end)
# end)
def validates_unique(*atts)
opts = default_validation_helpers_options(:unique)
if atts.last.is_a?(Hash)
- opts = opts.merge(atts.pop)
+ opts = Hash[opts].merge!(atts.pop)
end
message = validation_error_message(opts[:message])
where = opts[:where]
atts.each do |a|
arr = Array(a)
@@ -235,11 +235,11 @@
ds = opts[:dataset] || model.dataset
ds = if where
where.call(ds, self, arr)
else
vals = arr.map{|x| get_column_value(x)}
- next if vals.any?{|v| v.nil?}
+ next if vals.any?(&:nil?)
ds.where(arr.zip(vals))
end
ds = yield(ds) if block_given?
unless new?
h = ds.joined_dataset? ? qualified_pk_hash : pk_hash
@@ -277,10 +277,10 @@
end
# Merge the given options with the default options for the given type
# and call validatable_attributes with the merged options.
def validatable_attributes_for_type(type, atts, opts, &block)
- validatable_attributes(atts, default_validation_helpers_options(type).merge(opts), &block)
+ validatable_attributes(atts, Hash[default_validation_helpers_options(type)].merge!(opts), &block)
end
# The validation error message to use, as a string. If message
# is a Proc, call it with the args. Otherwise, assume it is a string and
# return it.