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

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

Overview

A card that includes Abstract::SolidCache has its "core" view fully rendered and stored in a '+*solid cache' card. If that card exists the core view returns its content as rendered view.

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

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, #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

Class Method Details

.included(host_class) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'tmpsets/set/mod012-solid_cache/abstract/solid_cache.rb', line 20

def self.included host_class
  host_class.format(host_class.try(:cached_format) || :base) do
    view :core, cache: :never do
      return super() if voo.hide? :solid_cache
      _render_solid_cache
    end

    view :solid_cache, cache: :never do
      card.with_solid_cache do |cache_card|
        subformat(cache_card)._render_core
      end
    end
  end
end

.source_locationObject



12
# File 'tmpsets/set/mod012-solid_cache/abstract/solid_cache.rb', line 12

def self.source_location; "/Users/ethan/dev/decko/gem/card/mod/solid_cache/set/abstract/solid_cache.rb"; end

Instance Method Details

#expire_solid_cache(_changed_card = nil) ⇒ Object



92
93
94
95
96
97
# File 'tmpsets/set/mod012-solid_cache/abstract/solid_cache.rb', line 92

def expire_solid_cache _changed_card=nil
  return unless solid_cache? && solid_cache_card.real?
  Auth.as_bot do
    solid_cache_card.delete!
  end
end

#generate_content_for_cacheObject



106
107
108
109
# File 'tmpsets/set/mod012-solid_cache/abstract/solid_cache.rb', line 106

def generate_content_for_cache
  format_type = try(:cached_format) || :base
  format(format_type)._render_core hide: :solid_cache
end

#update_solid_cacheObject



99
100
101
102
103
104
# File 'tmpsets/set/mod012-solid_cache/abstract/solid_cache.rb', line 99

def update_solid_cache
  return unless solid_cache?
  new_content = generate_content_for_cache
  write_to_solid_cache new_content
  new_content
end

#with_solid_cache {|solid_cache_card| ... } ⇒ Object

Yields:

  • (solid_cache_card)


87
88
89
90
# File 'tmpsets/set/mod012-solid_cache/abstract/solid_cache.rb', line 87

def with_solid_cache
  update_solid_cache if solid_cache_card.new?
  yield solid_cache_card
end

#write_to_solid_cache(new_content) ⇒ Object



111
112
113
# File 'tmpsets/set/mod012-solid_cache/abstract/solid_cache.rb', line 111

def write_to_solid_cache new_content
  solid_cache_card.write! new_content
end