Class: Primer::Octicon::Cache
- Inherits:
-
Object
- Object
- Primer::Octicon::Cache
- Defined in:
- app/lib/primer/octicon/cache.rb
Overview
:nodoc:
Constant Summary collapse
- LOOKUP =
{}
- PRELOADED_ICONS =
Preload the top 20 used icons.
[:alert, :check, :"chevron-down", :paste, :clock, :"dot-fill", :info, :"kebab-horizontal", :link, :lock, :mail, :pencil, :plus, :question, :repo, :search, :"shield-lock", :star, :trash, :x].freeze
Class Method Summary collapse
- .clear! ⇒ Object
- .get_key(symbol:, size:, width: nil, height: nil) ⇒ Object
-
.limit ⇒ Object
Cache size limit.
- .preload! ⇒ Object
- .read(key) ⇒ Object
- .set(key, value) ⇒ Object
Class Method Details
.clear! ⇒ Object
34 35 36 |
# File 'app/lib/primer/octicon/cache.rb', line 34 def clear! LOOKUP.clear end |
.get_key(symbol:, size:, width: nil, height: nil) ⇒ Object
12 13 14 15 16 |
# File 'app/lib/primer/octicon/cache.rb', line 12 def get_key(symbol:, size:, width: nil, height: nil) attrs = { symbol: symbol, size: size, width: width, height: height } attrs.compact! attrs.hash end |
.limit ⇒ Object
Cache size limit.
23 24 25 |
# File 'app/lib/primer/octicon/cache.rb', line 23 def limit 500 end |
.preload! ⇒ Object
38 39 40 |
# File 'app/lib/primer/octicon/cache.rb', line 38 def preload! PRELOADED_ICONS.each { |icon| Primer::Beta::Octicon.new(icon: icon) } end |
.read(key) ⇒ Object
18 19 20 |
# File 'app/lib/primer/octicon/cache.rb', line 18 def read(key) LOOKUP[key] end |