Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up remaining #to_miq_a callers that are covered by tests #20379

Merged
merged 2 commits into from
Jul 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/models/miq_alert.rb
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def self.evaluate_hourly_timer
end

def evaluate_queue(targets, inputs = {})
targets.to_miq_a.each do |target|
Array.wrap(targets).each do |target|
zone = target.respond_to?(:my_zone) ? target.my_zone : MiqServer.my_zone
MiqQueue.put_unless_exists(
:class_name => self.class.name,
Expand Down Expand Up @@ -316,7 +316,7 @@ def build_actions
notifications = (self.options ||= {})[:notifications]
notifications.each_key do |k|
if k == :email
notifications[k].to_miq_a.each do |n|
Array.wrap(notifications[k]).each do |n|
n[:to].each do |to|
description = "#{k.to_s.titleize} Action To: [#{to}] for Alert: #{self.description}"
actions << MiqAction.new(
Expand Down
2 changes: 1 addition & 1 deletion app/models/miq_report/generator/aggregation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def build_subtotals(all_dims = false)
end

def generate_subtotals(table, group_keys, options)
gkeys = group_keys.to_miq_a
gkeys = group_keys.kind_of?(String) ? group_keys.lines : Array.wrap(group_keys)
totals = {:count => 0, :row => {}}
group = {:count => 0, :row => {}}
result = {}
Expand Down
2 changes: 1 addition & 1 deletion app/models/miq_report/generator/sorting.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def build_sort_table

def build_sort_suffix_data
new_sortby = []
rpt_sortby = sortby.to_miq_a
rpt_sortby = Array.wrap(sortby)
rpt_sortby.each do |sb|
col, sfx = sb.split("__")
if sfx && self.class.is_break_suffix?(sfx)
Expand Down
2 changes: 1 addition & 1 deletion app/models/miq_request_task/dumping.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def dump_vim_array(ad, prefix, print_obj, print_method, &block)
def dump_obj(obj, prefix = nil, print_obj = STDOUT, print_method = :puts, options = {})
self.class.dump_obj(obj, prefix, print_obj, print_method) do |val, key|
value = val
if options.try(:[], :protected).try(:[], :path).to_miq_a.any? { |filter| key =~ filter }
if Array.wrap(options.try(:[], :protected).try(:[], :path)).any? { |filter| key =~ filter }
value = "<PROTECTED>"
end
print_obj.send(print_method, "#{key}(#{val.class}) = #{value.inspect}")
Expand Down
2 changes: 1 addition & 1 deletion app/models/mixins/relationship_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ def remove_all_parents(*args)
def remove_all_children(*args)
# Determine if we are removing all or some children
options = args.last.kind_of?(Hash) ? args.last : {}
of_type = options[:of_type].to_miq_a
of_type = Array.wrap(options[:of_type])
all_children_removed = of_type.empty? || (child_types - of_type).empty?

if self.is_root? && all_children_removed
Expand Down
6 changes: 3 additions & 3 deletions lib/miq_expression.rb
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ def self.quote(val, typ)
val.to_s.to_f_with_method
when "numeric_set"
val = val.split(",") if val.kind_of?(String)
v_arr = val.to_miq_a.flat_map do |v|
v_arr = Array.wrap(val).flat_map do |v|
if v.kind_of?(String)
v = begin
eval(v)
Expand All @@ -651,7 +651,7 @@ def self.quote(val, typ)
"[#{v_arr.join(",")}]"
when "string_set"
val = val.split(",") if val.kind_of?(String)
v_arr = val.to_miq_a.flat_map { |v| "'#{v.to_s.strip}'" }.uniq.sort
v_arr = Array.wrap(val).flat_map { |v| "'#{v.to_s.strip}'" }.uniq.sort
"[#{v_arr.join(",")}]"
else
val
Expand Down Expand Up @@ -1089,7 +1089,7 @@ def self.atom_error(field, operator, value)
when :date, :datetime
return false if operator.downcase.include?("empty")

values = value.to_miq_a
values = value.kind_of?(String) ? value.lines : Array.wrap(value)
return _("No Date/Time value specified") if values.empty? || values.include?(nil)
return _("Two Date/Time values must be specified") if operator.downcase == "from" && values.length < 2

Expand Down