Class: OkonomiUiKit::SvgIcons
- Inherits:
-
Object
- Object
- OkonomiUiKit::SvgIcons
- Defined in:
- app/helpers/okonomi_ui_kit/svg_icons.rb
Class Method Summary collapse
- .exist?(name) ⇒ Boolean
-
.file_name(name) ⇒ Object
Deprecated, kept for backwards compatibility.
- .file_path(name) ⇒ Object
- .read(name) ⇒ Object
- .registry ⇒ Object
Class Method Details
.exist?(name) ⇒ Boolean
10 11 12 |
# File 'app/helpers/okonomi_ui_kit/svg_icons.rb', line 10 def self.exist?(name) registry[name].present? || file_path(name).present? end |
.file_name(name) ⇒ Object
Deprecated, kept for backwards compatibility
27 28 29 |
# File 'app/helpers/okonomi_ui_kit/svg_icons.rb', line 27 def self.file_name(name) file_path(name) end |
.file_path(name) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/helpers/okonomi_ui_kit/svg_icons.rb', line 14 def self.file_path(name) # First check in the host application host_path = Rails.root.join("app", "assets", "images", "#{name}.svg") return host_path if File.exist?(host_path) # Fall back to the engine's icons engine_path = OkonomiUiKit::Engine.root.join("app", "assets", "images", "#{name}.svg") return engine_path if File.exist?(engine_path) nil end |
.read(name) ⇒ Object
5 6 7 8 |
# File 'app/helpers/okonomi_ui_kit/svg_icons.rb', line 5 def self.read(name) registry.merge!(name => File.read(file_path(name))) if registry[name].nil? registry[name] end |
.registry ⇒ Object
31 32 33 |
# File 'app/helpers/okonomi_ui_kit/svg_icons.rb', line 31 def self.registry @registry ||= {} end |