Module: Garner::Mixins::Mongoid::Document
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/garner/mixins/mongoid_document.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
-
#all_embedding_documents ⇒ Object
navigate the parent embedding document hierarchy.
-
#invalidate_api_cache ⇒ Object
invalidate API cache.
Instance Method Details
#all_embedding_documents ⇒ Object
navigate the parent embedding document hierarchy
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/garner/mixins/mongoid_document.rb', line 25 def obj = self docs = [] while obj. && obj. break if docs.detect { |doc| doc.class == obj.class } parent = obj.send(obj..inverse) docs << parent obj = parent end docs end |
#invalidate_api_cache ⇒ Object
invalidate API cache
14 15 16 17 18 19 20 21 22 |
# File 'lib/garner/mixins/mongoid_document.rb', line 14 def invalidate_api_cache self..each { |doc| doc.invalidate_api_cache } cache_class = self.class.api_cache_class || self.class Garner::Cache::ObjectIdentity::IDENTITY_FIELDS.each do |identity_field| next unless self.respond_to?(identity_field) Garner::Cache::ObjectIdentity.invalidate(cache_class, { identity_field => self.send(identity_field) }) end Garner::Cache::ObjectIdentity.invalidate(cache_class) end |