Class: Text::Gen::Store
- Inherits:
-
Object
- Object
- Text::Gen::Store
- Defined in:
- lib/text/gen/store.rb
Overview
Store is a local cache of a builder that is persistent per store to save time on database lookups or transformations.
Instance Method Summary collapse
- #add(key, builder) ⇒ Object
- #find(key) ⇒ Object
-
#initialize ⇒ Store
constructor
A new instance of Store.
- #to_h ⇒ Object
Constructor Details
#initialize ⇒ Store
Returns a new instance of Store.
8 9 10 |
# File 'lib/text/gen/store.rb', line 8 def initialize @store = {} end |
Instance Method Details
#add(key, builder) ⇒ Object
16 17 18 |
# File 'lib/text/gen/store.rb', line 16 def add(key, builder) @store[key.to_s.downcase] = builder end |
#find(key) ⇒ Object
12 13 14 |
# File 'lib/text/gen/store.rb', line 12 def find(key) @store[key.to_s.downcase] end |
#to_h ⇒ Object
20 21 22 |
# File 'lib/text/gen/store.rb', line 20 def to_h @store end |