Class: Plum::ThemeRegistry

Inherits:
Object
  • Object
show all
Defined in:
app/services/plum/theme_registry.rb

Constant Summary collapse

DEFAULT_THEME_HANDLE =
"default"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(theme_paths: Plum.configuration.theme_paths) ⇒ ThemeRegistry

Returns a new instance of ThemeRegistry.



11
12
13
# File 'app/services/plum/theme_registry.rb', line 11

def initialize(theme_paths: Plum.configuration.theme_paths)
  @theme_paths = Array(theme_paths).compact.map { |path| Pathname(path).expand_path }.uniq(&:to_s)
end

Instance Attribute Details

#theme_pathsObject (readonly)

Returns the value of attribute theme_paths.



9
10
11
# File 'app/services/plum/theme_registry.rb', line 9

def theme_paths
  @theme_paths
end

Instance Method Details

#allObject



15
16
17
# File 'app/services/plum/theme_registry.rb', line 15

def all
  themes_by_handle.values
end

#default_themeObject



27
28
29
# File 'app/services/plum/theme_registry.rb', line 27

def default_theme
  find(DEFAULT_THEME_HANDLE)
end

#fetch(handle) ⇒ Object



23
24
25
# File 'app/services/plum/theme_registry.rb', line 23

def fetch(handle)
  find(handle) || default_theme
end

#find(handle) ⇒ Object



19
20
21
# File 'app/services/plum/theme_registry.rb', line 19

def find(handle)
  themes_by_handle[handle.to_s] if handle.present?
end