Class: Middleman::CachingProxy::Extension
- Inherits:
-
Extension
- Object
- Extension
- Middleman::CachingProxy::Extension
- Defined in:
- lib/middleman/caching_proxy/extension.rb
Defined Under Namespace
Modules: InstanceMethods
Instance Attribute Summary collapse
-
#add_to_cache ⇒ Object
readonly
Returns the value of attribute add_to_cache.
-
#copy_from_cache ⇒ Object
readonly
Returns the value of attribute copy_from_cache.
Instance Method Summary collapse
- #add(item) ⇒ Object
- #after_build(_builder) ⇒ Object
-
#initialize(app, options_hash = {}, &block) ⇒ Extension
constructor
A new instance of Extension.
- #manipulate_resource_list(resources) ⇒ Object
Constructor Details
#initialize(app, options_hash = {}, &block) ⇒ Extension
Returns a new instance of Extension.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/middleman/caching_proxy/extension.rb', line 39 def initialize(app, = {}, &block) super if Semantic::Version.new(Middleman::VERSION).major <= 3 app.send :include, InstanceMethods end if !.cache_key raise "Please supply a cache_key value" end @copy_from_cache = [] @add_to_cache = [] @cache = nil end |
Instance Attribute Details
#add_to_cache ⇒ Object (readonly)
Returns the value of attribute add_to_cache.
37 38 39 |
# File 'lib/middleman/caching_proxy/extension.rb', line 37 def add_to_cache @add_to_cache end |
#copy_from_cache ⇒ Object (readonly)
Returns the value of attribute copy_from_cache.
36 37 38 |
# File 'lib/middleman/caching_proxy/extension.rb', line 36 def copy_from_cache @copy_from_cache end |
Instance Method Details
#add(item) ⇒ Object
64 65 66 67 68 69 70 71 72 |
# File 'lib/middleman/caching_proxy/extension.rb', line 64 def add(item) if cache.has?(item) copy_from_cache << item true else add_to_cache << item false end end |
#after_build(_builder) ⇒ Object
59 60 61 62 |
# File 'lib/middleman/caching_proxy/extension.rb', line 59 def after_build(_builder) copy_new_files_to_cache cache.save end |
#manipulate_resource_list(resources) ⇒ Object
55 56 57 |
# File 'lib/middleman/caching_proxy/extension.rb', line 55 def manipulate_resource_list(resources) resources + cached_resources end |