Module: Erector::Caching
- Defined in:
- lib/erector/caching.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
- #_render(options = {}) ⇒ Object
- #_render_via(parent, options = {}) ⇒ Object
- #cache ⇒ Object
- #should_cache? ⇒ Boolean
Class Method Details
.included(base) ⇒ Object
38 39 40 |
# File 'lib/erector/caching.rb', line 38 def self.included(base) base.extend ClassMethods end |
Instance Method Details
#_render(options = {}) ⇒ Object
76 77 78 79 80 81 82 |
# File 'lib/erector/caching.rb', line 76 def _render( = {}) if should_cache? cache[self.class, assigns, [:content_method_name]] ||= super else super end end |
#_render_via(parent, options = {}) ⇒ Object
84 85 86 87 88 89 90 91 |
# File 'lib/erector/caching.rb', line 84 def _render_via(parent, = {}) if should_cache? parent.output << cache[self.class, assigns, [:content_method_name]] ||= parent.capture { super } parent.output. << self.class # todo: test!!! else super end end |
#cache ⇒ Object
68 69 70 |
# File 'lib/erector/caching.rb', line 68 def cache self.class.cache end |
#should_cache? ⇒ Boolean
72 73 74 |
# File 'lib/erector/caching.rb', line 72 def should_cache? cache && block.nil? && self.class.cachable? end |