Sha256: 921e639072f454aa877e0884a803bcdc38002e1c30c6ba5cffd64e6c0a9f29b9

Contents?: true

Size: 963 Bytes

Versions: 124

Compression:

Stored size: 963 Bytes

Contents

# frozen_string_literal: true

module Proscenium
  module CssModule::Path
    # Returns the path to the CSS module file for this class, where the file is located alongside
    # the class file, and has the same name as the class file, but with a `.module.css` extension.
    #
    # If the CSS module file does not exist, it's ancestry is checked, returning the first that
    # exists. Then finally `nil` is returned if never found.
    #
    # @return [Pathname]
    def css_module_path
      return @css_module_path if instance_variable_defined?(:@css_module_path)

      path = source_path.sub_ext('.module.css')
      @css_module_path = path.exist? ? path : nil

      unless @css_module_path
        klass = superclass

        while klass.respond_to?(:css_module_path) && !klass.abstract_class
          break if (@css_module_path = klass.css_module_path)

          klass = klass.superclass
        end
      end

      @css_module_path
    end
  end
end

Version data entries

124 entries across 124 versions & 1 rubygems

Version Path
proscenium-0.19.0.beta4-x86_64-linux lib/proscenium/css_module/path.rb
proscenium-0.19.0.beta4-aarch64-linux lib/proscenium/css_module/path.rb
proscenium-0.19.0.beta4-arm64-darwin lib/proscenium/css_module/path.rb
proscenium-0.19.0.beta4-x86_64-darwin lib/proscenium/css_module/path.rb
proscenium-0.19.0.beta4 lib/proscenium/css_module/path.rb
proscenium-0.19.0.beta3-x86_64-linux lib/proscenium/css_module/path.rb
proscenium-0.19.0.beta3-aarch64-linux lib/proscenium/css_module/path.rb
proscenium-0.19.0.beta3-arm64-darwin lib/proscenium/css_module/path.rb
proscenium-0.19.0.beta3-x86_64-darwin lib/proscenium/css_module/path.rb
proscenium-0.19.0.beta3 lib/proscenium/css_module/path.rb
proscenium-0.19.0.beta2-x86_64-linux lib/proscenium/css_module/path.rb
proscenium-0.19.0.beta2-aarch64-linux lib/proscenium/css_module/path.rb
proscenium-0.19.0.beta2-arm64-darwin lib/proscenium/css_module/path.rb
proscenium-0.19.0.beta2-x86_64-darwin lib/proscenium/css_module/path.rb
proscenium-0.19.0.beta2 lib/proscenium/css_module/path.rb
proscenium-0.19.0.beta1-x86_64-linux lib/proscenium/css_module/path.rb
proscenium-0.19.0.beta1-aarch64-linux lib/proscenium/css_module/path.rb
proscenium-0.19.0.beta1-arm64-darwin lib/proscenium/css_module/path.rb
proscenium-0.19.0.beta1-x86_64-darwin lib/proscenium/css_module/path.rb
proscenium-0.19.0.beta1 lib/proscenium/css_module/path.rb