diff --git a/Gemfile.lock b/Gemfile.lock index 29562891f..394d4bb16 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -141,7 +141,7 @@ GEM websocket-driver (~> 0.7) globalid (1.3.0) activesupport (>= 6.1) - haml (7.1.0) + haml (7.2.0) temple (>= 0.8.2) thor tilt @@ -211,13 +211,13 @@ GEM nokogiri (1.19.0-x86_64-linux-musl) racc (~> 1.4) parallel (1.27.0) - parser (3.3.10.0) + parser (3.3.10.1) ast (~> 2.4.1) racc pp (0.6.3) prettyprint prettyprint (0.2.0) - prism (1.7.0) + prism (1.8.0) propshaft (1.3.1) actionpack (>= 7.0.0) activesupport (>= 7.0.0) @@ -269,7 +269,7 @@ GEM zeitwerk (~> 2.6) rainbow (3.1.1) rake (13.3.1) - rdoc (7.0.3) + rdoc (7.1.0) erb psych (>= 4.0.0) tsort @@ -301,7 +301,7 @@ GEM rspec-mocks (~> 3.13) rspec-support (~> 3.13) rspec-support (3.13.6) - rubocop (1.81.7) + rubocop (1.82.1) json (~> 2.3) language_server-protocol (~> 3.17.0.2) lint_roller (~> 1.1.0) @@ -309,7 +309,7 @@ GEM parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 2.9.3, < 3.0) - rubocop-ast (>= 1.47.1, < 2.0) + rubocop-ast (>= 1.48.0, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 4.0) rubocop-ast (1.49.0) @@ -353,10 +353,10 @@ GEM actionpack (>= 6.1) activesupport (>= 6.1) sprockets (>= 3.0.0) - standard (1.52.0) + standard (1.53.0) language_server-protocol (~> 3.17.0.2) lint_roller (~> 1.0) - rubocop (~> 1.81.7) + rubocop (~> 1.82.0) standard-custom (~> 1.0.0) standard-performance (~> 1.8) standard-custom (1.0.2) diff --git a/Rakefile b/Rakefile index c81db4fe4..4f0afd44f 100644 --- a/Rakefile +++ b/Rakefile @@ -69,10 +69,10 @@ namespace :docs do .get("ViewComponent::Base") .meths .select do |method| - !method.tag(:private) && - method.path.include?("ViewComponent::Base") && - method.visibility == :public && - !method[:name].to_s.start_with?("_") # Ignore methods we mark as internal by prefixing with underscores + !method.tag(:private) && + method.path.include?("ViewComponent::Base") && + method.visibility == :public && + !method[:name].to_s.start_with?("_") # Ignore methods we mark as internal by prefixing with underscores end.sort_by { |method| method[:name] } instance_methods_to_document = meths.select { |method| method.scope != :class } @@ -83,8 +83,8 @@ namespace :docs do .meths .sort_by { |method| method[:name] } .select do |method| - !method.tag(:private) && - method.visibility == :public + !method.tag(:private) && + method.visibility == :public end require "rails" diff --git a/lib/view_component/base.rb b/lib/view_component/base.rb index c6d75acaa..3f1e0eb61 100644 --- a/lib/view_component/base.rb +++ b/lib/view_component/base.rb @@ -577,7 +577,7 @@ def inherited(child) # eager loading is disabled and the parent component is rendered before the child. In # such a scenario, the parent will override ViewComponent::Base#render_template_for, # meaning it will not be called for any children and thus not compile their templates. - if !child.instance_methods(false).include?(:render_template_for) && !child.__vc_compiled? + if !child.method_defined?(:render_template_for, false) && !child.__vc_compiled? child.class_eval <<~RUBY, __FILE__, __LINE__ + 1 def render_template_for(requested_details) # Force compilation here so the compiler always redefines render_template_for. @@ -600,7 +600,7 @@ def render_template_for(requested_details) # Set collection parameter to the extended component child.with_collection_parameter(__vc_provided_collection_parameter) - if instance_methods(false).include?(:render_template_for) + if method_defined?(:render_template_for, false) vc_ancestor_calls = defined?(@__vc_ancestor_calls) ? @__vc_ancestor_calls.dup : [] vc_ancestor_calls.unshift(instance_method(:render_template_for)) diff --git a/lib/view_component/compiler.rb b/lib/view_component/compiler.rb index 018c342ac..69b555046 100644 --- a/lib/view_component/compiler.rb +++ b/lib/view_component/compiler.rb @@ -115,11 +115,11 @@ def template_errors .tally .select { |_, count| count > 1 } .each do |tally| - variant, this_format = tally.first + variant, this_format = tally.first - variant_string = " for variant `#{variant}`" if variant.present? + variant_string = " for variant `#{variant}`" if variant.present? - errors << "More than one #{this_format.upcase} template found#{variant_string} for #{@component}. " + errors << "More than one #{this_format.upcase} template found#{variant_string} for #{@component}. " end default_template_types = @templates.each_with_object(Set.new) do |template, memo| @@ -190,11 +190,11 @@ def gather_templates ).flat_map { |ancestor| ancestor.instance_methods(false).grep(/^call(_|$)/) } .uniq .each do |method_name| - templates << Template::InlineCall.new( - component: @component, - method_name: method_name, - defined_on_self: component_instance_methods_on_self.include?(method_name) - ) + templates << Template::InlineCall.new( + component: @component, + method_name: method_name, + defined_on_self: component_instance_methods_on_self.include?(method_name) + ) end templates diff --git a/lib/view_component/slotable.rb b/lib/view_component/slotable.rb index 03f745f20..f1625080d 100644 --- a/lib/view_component/slotable.rb +++ b/lib/view_component/slotable.rb @@ -259,7 +259,7 @@ def __vc_register_polymorphic_slot(slot_name, types, collection:) setter_method_name = :"with_#{poly_slot_name}" - if instance_methods.include?(setter_method_name) + if method_defined?(setter_method_name) raise AlreadyDefinedPolymorphicSlotSetterError.new(setter_method_name, poly_slot_name) end