This rule was introduced in RuboCop 1.68 to encourage passing additional keyword arguments directly instead of using merge.
21 lines
527 B
Ruby
21 lines
527 B
Ruby
class Admin::AllowedTableActionsComponent < ApplicationComponent
|
|
attr_reader :record, :options
|
|
use_helpers :can?
|
|
delegate :action, to: :table_actions_component
|
|
|
|
def initialize(record, **options)
|
|
@record = record
|
|
@options = options
|
|
end
|
|
|
|
private
|
|
|
|
def actions
|
|
(options[:actions] || [:edit, :destroy]).select { |action| can?(action, record) }
|
|
end
|
|
|
|
def table_actions_component
|
|
@table_actions_component ||= Admin::TableActionsComponent.new(record, **options, actions: actions)
|
|
end
|
|
end
|