Class: Card::Virtual
- Inherits:
-
Cardio::Record
- Object
- Cardio::Record
- Card::Virtual
- Defined in:
- lib/card/virtual.rb
Overview
Model for the card_virtuals table. It provides method to get and store content for virtual cards from the card_virtuals table.
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.delete(card) ⇒ Object
24 25 26 27 |
# File 'lib/card/virtual.rb', line 24 def delete card cache.delete card.key find_by_card(card)&.delete end |
.fetch(card) ⇒ Object
14 15 16 17 18 |
# File 'lib/card/virtual.rb', line 14 def fetch card cache.fetch card.key do find_by_card(card) || create(card) end end |
.save(card) ⇒ Object
20 21 22 |
# File 'lib/card/virtual.rb', line 20 def save card cache.write card.key, create_or_update(card) end |
Instance Method Details
#update(new_content) ⇒ Object
8 9 10 11 |
# File 'lib/card/virtual.rb', line 8 def update new_content content == new_content ? touch : update!(content: new_content) new_content end |