Class: Glyphs::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/glyphs/configuration.rb

Constant Summary collapse

DEFAULT_FALLBACK_ICONS =
{
  lucide: "circle-question-mark",
  phosphor: "question",
  heroicons: "question-mark-circle"
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



19
20
21
22
23
24
# File 'lib/glyphs/configuration.rb', line 19

def initialize
  @raise_on_missing = defined?(Rails) ? Rails.env.local? : true
  @on_missing_icon = nil
  @fallback_icons = DEFAULT_FALLBACK_ICONS.dup
  @cache_svgs = true
end

Instance Attribute Details

#cache_svgsObject

raise_on_missing: boolean; when true, Icons::IconNotFound is re-raised. Defaults to true in local Rails environments (and outside Rails). on_missing_icon: optional callable(error, name:, library:, variant:), invoked before the fallback renders when not raising. fallback_icons: { library => icon_name } rendered instead of a missing icon. cache_svgs: memoize rendered SVG strings per [library, variant, name, attributes].



17
18
19
# File 'lib/glyphs/configuration.rb', line 17

def cache_svgs
  @cache_svgs
end

#fallback_iconsObject

raise_on_missing: boolean; when true, Icons::IconNotFound is re-raised. Defaults to true in local Rails environments (and outside Rails). on_missing_icon: optional callable(error, name:, library:, variant:), invoked before the fallback renders when not raising. fallback_icons: { library => icon_name } rendered instead of a missing icon. cache_svgs: memoize rendered SVG strings per [library, variant, name, attributes].



17
18
19
# File 'lib/glyphs/configuration.rb', line 17

def fallback_icons
  @fallback_icons
end

#on_missing_iconObject

raise_on_missing: boolean; when true, Icons::IconNotFound is re-raised. Defaults to true in local Rails environments (and outside Rails). on_missing_icon: optional callable(error, name:, library:, variant:), invoked before the fallback renders when not raising. fallback_icons: { library => icon_name } rendered instead of a missing icon. cache_svgs: memoize rendered SVG strings per [library, variant, name, attributes].



17
18
19
# File 'lib/glyphs/configuration.rb', line 17

def on_missing_icon
  @on_missing_icon
end

#raise_on_missingObject

raise_on_missing: boolean; when true, Icons::IconNotFound is re-raised. Defaults to true in local Rails environments (and outside Rails). on_missing_icon: optional callable(error, name:, library:, variant:), invoked before the fallback renders when not raising. fallback_icons: { library => icon_name } rendered instead of a missing icon. cache_svgs: memoize rendered SVG strings per [library, variant, name, attributes].



17
18
19
# File 'lib/glyphs/configuration.rb', line 17

def raise_on_missing
  @raise_on_missing
end