Module: ThreeD::ModelFragments::ClassMethods
- Defined in:
- lib/three_d/model_fragments.rb
Instance Method Summary collapse
Instance Method Details
#cache_helper ⇒ Object
44 45 46 47 |
# File 'lib/three_d/model_fragments.rb', line 44 def cache_helper # TODO: Here should be the real ActionController caching funtionality #ActionController::Caching::Fragments.new end |
#has_model_fragments? ⇒ Boolean
40 41 42 |
# File 'lib/three_d/model_fragments.rb', line 40 def has_model_fragments? self.included_modules.include?(InstanceMethods) end |
#model_fragments ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/three_d/model_fragments.rb', line 15 def model_fragments unless has_model_fragments? if ActionController::Base.cache_store.inspect.match("FileStore") self.send :include, InstanceMethods cattr_accessor :caching_path, :allowed_fragments self.caching_path = ActionController::Base.cache_store.cache_path self.after_save :clear_view_cache self.after_destroy :clear_view_cache # TODO: Build hash or array based settings # to allow only specified fragments to get called. # Provide group ability to clear groups of fragments like # :customers => %w(frag_a frag_b frag_c) # user.clear_view_cache_group(:customers) # => frag_a, frag_b frag_c get wiped! self.allowed_fragments = [] else raise "Currently, ModelFragments only support FileStore\nPlease set 'ActionController::Base.cache_store = :file_store, /path/to/cache'" end end end |