Class: SmartCollection::Associations::SmartCollectionAssociation

Inherits:
ActiveRecord::Associations::HasManyAssociation
  • Object
show all
Defined in:
lib/smart_collection/associations/smart_collection_association.rb

Defined Under Namespace

Classes: ScopeBuilder

Instance Method Summary collapse

Instance Method Details

#association_scopeObject



50
51
52
53
54
55
56
57
58
59
# File 'lib/smart_collection/associations/smart_collection_association.rb', line 50

def association_scope
  if cache_manager = reflection.options[:smart_collection].cache_manager
    unless cache_manager.cache_exists? owner
      owner.update_cache
    end
    cached_scope
  else
    uncached_scope
  end
end

#cached_scopeObject



69
70
71
# File 'lib/smart_collection/associations/smart_collection_association.rb', line 69

def cached_scope
  reflection.options[:smart_collection].cache_manager.read_scope owner
end

#skip_statement_cache?Boolean

Returns:

  • (Boolean)


61
62
63
# File 'lib/smart_collection/associations/smart_collection_association.rb', line 61

def skip_statement_cache?
  true
end

#uncached_scopeObject



65
66
67
# File 'lib/smart_collection/associations/smart_collection_association.rb', line 65

def uncached_scope
  ScopeBuilder.new(owner.rule, reflection.klass).build
end