@@ -457,8 +457,16 @@ def compiler
457457 # Defaults to `false`.
458458
459459 class << self
460+ # The file path of the component Ruby file.
461+ #
462+ # @return [String]
463+ attr_reader :identifier
464+
465+ # @private
466+ attr_writer :identifier
467+
460468 # @private
461- attr_accessor :source_location , : virtual_path
469+ attr_accessor :virtual_path
462470
463471 # Find sidecar files for the given extensions.
464472 #
@@ -468,13 +476,13 @@ class << self
468476 # For example, one might collect sidecar CSS files that need to be compiled.
469477 # @param extensions [Array<String>] Extensions of which to return matching sidecar files.
470478 def sidecar_files ( extensions )
471- return [ ] unless source_location
479+ return [ ] unless identifier
472480
473481 extensions = extensions . join ( "," )
474482
475483 # view files in a directory named like the component
476- directory = File . dirname ( source_location )
477- filename = File . basename ( source_location , ".rb" )
484+ directory = File . dirname ( identifier )
485+ filename = File . basename ( identifier , ".rb" )
478486 component_name = name . demodulize . underscore
479487
480488 # Add support for nested components defined in the same file.
@@ -499,7 +507,7 @@ def sidecar_files(extensions)
499507
500508 sidecar_directory_files = Dir [ "#{ directory } /#{ component_name } /#{ filename } .*{#{ extensions } }" ]
501509
502- ( sidecar_files - [ source_location ] + sidecar_directory_files + nested_component_files ) . uniq
510+ ( sidecar_files - [ identifier ] + sidecar_directory_files + nested_component_files ) . uniq
503511 end
504512
505513 # Render a component for each element in a collection ([documentation](/guide/collections)):
@@ -548,11 +556,11 @@ def render_template_for(variant = nil, format = nil)
548556 # has been re-defined by the consuming application, likely in ApplicationComponent.
549557 # We use `base_label` method here instead of `label` to avoid cases where the method
550558 # owner is included in a prefix like `ApplicationComponent.inherited`.
551- child . source_location = caller_locations ( 1 , 10 ) . reject { |l | l . base_label == "inherited" } [ 0 ] . path
559+ child . identifier = caller_locations ( 1 , 10 ) . reject { |l | l . base_label == "inherited" } [ 0 ] . path
552560
553561 # If Rails application is loaded, removes the first part of the path and the extension.
554562 if defined? ( Rails ) && Rails . application
555- child . virtual_path = child . source_location . gsub (
563+ child . virtual_path = child . identifier . gsub (
556564 /(.*#{ Regexp . quote ( ViewComponent ::Base . config . view_component_path ) } )|(\. rb)/ , ""
557565 )
558566 end
@@ -590,15 +598,6 @@ def compiler
590598 @__vc_compiler ||= Compiler . new ( self )
591599 end
592600
593- # @private
594- def identifier
595- # :nocov:
596- Kernel . warn ( "WARNING: The #{ self . class } .identifier is undocumented and was meant for internal framework usage only. As it is no longer used by the framework it will be removed in a coming non-breaking ViewComponent release." )
597-
598- source_location
599- # :nocov:
600- end
601-
602601 # Set the parameter name used when rendering elements of a collection ([documentation](/guide/collections)):
603602 #
604603 # ```ruby
0 commit comments