From d55a7f76f177c41e0e9e321178ae8b56059edcf9 Mon Sep 17 00:00:00 2001 From: Geremia Taglialatela Date: Tue, 24 Oct 2023 23:22:57 +0200 Subject: [PATCH] Autofix save RuboCop performance offenses - Performance/BlockGivenWithExplicitBlock - Performance/StringReplacement --- lib/arbre/context.rb | 2 +- lib/arbre/element/builder_methods.rb | 4 ++-- lib/arbre/html/tag.rb | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/arbre/context.rb b/lib/arbre/context.rb index b197e630..16a1b4b9 100644 --- a/lib/arbre/context.rb +++ b/lib/arbre/context.rb @@ -44,7 +44,7 @@ def initialize(assigns = {}, helpers = nil, &block) @_current_arbre_element_buffer = [self] super(self) - instance_eval(&block) if block_given? + instance_eval(&block) if block end def arbre_context diff --git a/lib/arbre/element/builder_methods.rb b/lib/arbre/element/builder_methods.rb index a9ffe9ab..89aafb1c 100644 --- a/lib/arbre/element/builder_methods.rb +++ b/lib/arbre/element/builder_methods.rb @@ -25,11 +25,11 @@ def build_tag(klass, *args, &block) tag.parent = current_arbre_element with_current_arbre_element tag do - if block_given? && block.arity > 0 + if block && block.arity > 0 tag.build(*args, &block) else tag.build(*args) - append_return_block(yield) if block_given? + append_return_block(yield) if block end end diff --git a/lib/arbre/html/tag.rb b/lib/arbre/html/tag.rb index f33b86ba..12b334f8 100644 --- a/lib/arbre/html/tag.rb +++ b/lib/arbre/html/tag.rb @@ -165,7 +165,7 @@ def dom_class_name_for(record) if record.class.respond_to?(:model_name) record.class.model_name.singular else - record.class.name.underscore.gsub("/", "_") + record.class.name.underscore.tr("/", "_") end end