Skip to content

Commit

Permalink
Fixes #37103 - Ruby 3.0 support
Browse files Browse the repository at this point in the history
  • Loading branch information
ofedoren committed Feb 12, 2024
1 parent 5c2d1fb commit ca4eaf2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ AllCops:
- 'node_modules/**/*'
- 'locale/*'
- 'vendor/**/*'
TargetRubyVersion: 2.5
TargetRubyVersion: 2.7

Lint/ShadowingOuterLocalVariable:
Enabled: false
Expand Down
9 changes: 8 additions & 1 deletion app/lib/actions/bulk_action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ class BulkAction < Actions::ActionWithSubPlans
# Arguments that all the targets share
def plan(action_class, targets, *args, concurrency_limit: nil, **kwargs)
check_targets!(targets)
limit_concurrency_level!(concurrency_limit) if concurrency_limit
extracted_concurrency_limit = extract_concurrency_limit(args, concurrency_limit)
limit_concurrency_level!(extracted_concurrency_limit) if extracted_concurrency_limit
plan_self(:action_class => action_class.to_s,
:target_ids => targets.map(&:id),
:target_class => targets.first.class.to_s,
Expand Down Expand Up @@ -72,5 +73,11 @@ def batch(from, size)
def total_count
input[:target_ids].count
end

private

def extract_concurrency_limit(args = [], limit = nil)
args.find { |arg| arg.is_a?(Hash) && arg.key?(:concurrency_limit) }&.fetch(:concurrency_limit, limit)
end
end
end
16 changes: 8 additions & 8 deletions app/models/foreman_tasks/concerns/action_triggering.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ def update_action; end
# @override
def destroy_action; end

def save(*args)
dynflow_task_wrap(:save) { super(*args) }
def save(...)
dynflow_task_wrap(:save) { super(...) }
end

def save!(*args)
dynflow_task_wrap(:save) { super(*args) }
def save!(...)
dynflow_task_wrap(:save) { super(...) }
end

def destroy
Expand All @@ -37,14 +37,14 @@ def destroy

# In order to use host.<attribute>_changed?, we must assign_attributes to
# the host record for these update and update! methods.
def update(*args)
assign_attributes(*args)
def update(...)
assign_attributes(...)
dynflow_task_wrap(:save) { save }
end
alias update_attributes update

def update!(*args)
assign_attributes(*args)
def update!(...)
assign_attributes(...)
dynflow_task_wrap(:save) { save! }
end
alias update_attributes! update!
Expand Down

0 comments on commit ca4eaf2

Please sign in to comment.