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 Helpers

Helpers::SET_PATTERN_TEST_REGEXP

Instance Method Summary collapse

Methods included from Card::Set

reset_modules

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

#method_missing, #num_set_parts, #pattern_code, #respond_to_missing?, #set_name_parts, #shortname, #underscore

Methods included from Card::Set::AdvancedApi

#attachment, #ensure_set, #stage_method

Methods included from Format

#before, #format, layout_method_name, #view, view_method_name, view_setting_method_name, wrapper_method_name

Methods included from Inheritance

#include_set, #include_set_formats

Methods included from Basket

#abstract_basket, #add_to_basket, #basket, #unshift_basket

Methods included from Trait

#card_accessor, #card_reader, #card_writer, #require_field

Methods included from Event::Api

#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