Class: Plum::ThemeRegistry
- Inherits:
-
Object
- Object
- Plum::ThemeRegistry
- Defined in:
- app/services/plum/theme_registry.rb
Constant Summary collapse
- DEFAULT_THEME_HANDLE =
"default"
Instance Attribute Summary collapse
-
#theme_paths ⇒ Object
readonly
Returns the value of attribute theme_paths.
Instance Method Summary collapse
- #all ⇒ Object
- #default_theme ⇒ Object
- #fetch(handle) ⇒ Object
- #find(handle) ⇒ Object
-
#initialize(theme_paths: Plum.configuration.theme_paths) ⇒ ThemeRegistry
constructor
A new instance of ThemeRegistry.
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). }.uniq(&:to_s) end |
Instance Attribute Details
#theme_paths ⇒ Object (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
#all ⇒ Object
15 16 17 |
# File 'app/services/plum/theme_registry.rb', line 15 def all themes_by_handle.values end |
#default_theme ⇒ Object
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 |