Module: Card::Set::Abstract::SolidCache

Extended by:
Card::Set
Defined in:
tmpsets/set/mod009-solid_cache/abstract/solid_cache.rb

Defined Under Namespace

Modules: ClassMethods

Constant Summary

Constants included from Format

Format::TEMPLATE_DIR

Instance Method Summary collapse

Methods included from I18nScope

#mod_name, #scope

Methods included from Loader

#clean_empty_module_from_hash, #clean_empty_modules, #extended, #process_base_modules, #register_set

Methods included from Helpers

#abstract_set?, #all_set?, #num_set_parts, #shortname

Methods included from Card::Set::AdvancedApi

#attachment, #ensure_set, #stage_method

Methods included from Format

#all_set_format_mod!, #define_on_format, #format, #register_set_format, #view

Methods included from Inheritance

#include_set, #include_set_formats

Methods included from Basket

#abstract_basket, #add_to_basket, #basket

Methods included from Trait

#card_accessor, #card_reader, #card_writer

Methods included from Event

#event

Instance Method Details

#expire_solid_cacheObject



78
79
80
81
82
83
# File 'tmpsets/set/mod009-solid_cache/abstract/solid_cache.rb', line 78

def expire_solid_cache
  return unless solid_cache?
  Auth.as_bot do
    solid_cache_card.delete!
  end
end

#update_solid_cacheObject



85
86
87
88
89
90
91
# File 'tmpsets/set/mod009-solid_cache/abstract/solid_cache.rb', line 85

def update_solid_cache
  return unless solid_cache?
  new_content = format(:html)._render_core(solid_cache: false)
  return unless new_content
  write_to_solid_cache new_content
  new_content
end

#write_to_solid_cache(new_content) ⇒ Object



93
94
95
96
97
98
99
100
101
102
# File 'tmpsets/set/mod009-solid_cache/abstract/solid_cache.rb', line 93

def write_to_solid_cache new_content
  Auth.as_bot do
    if solid_cache_card.new_card?
      solid_cache_card.update_attributes! content: new_content
    elsif new_content != solid_cache_card.content
      solid_cache_card.update_column :db_content, new_content
      solid_cache_card.expire
    end
  end
end