Class: ViewComponent::ScopedStyles::Railtie

Inherits:
Rails::Railtie
  • Object
show all
Defined in:
lib/view_component/scoped_styles/railtie.rb

Class Method Summary collapse

Class Method Details

.component_pathObject



28
29
30
31
32
33
34
# File 'lib/view_component/scoped_styles/railtie.rb', line 28

def component_path
  Rails.root.join(
    ViewComponent::ScopedStyles.configuration.components_path,
    "**",
    "*.rb"
  )
end

.load_and_register_componentsObject



36
37
38
39
40
# File 'lib/view_component/scoped_styles/railtie.rb', line 36

def load_and_register_components
  Dir[component_path].each { require_dependency _1 }

  register_components
end

.register_componentsObject



42
43
44
45
46
47
# File 'lib/view_component/scoped_styles/railtie.rb', line 42

def register_components
  ObjectSpace
    .each_object(Class)
    .select { _1.ancestors.include?(ViewComponent::ScopedStyles) }
    .each(&:register_styles)
end