module Kasket

Constants

CONFIGURATION
VERSION

Public Class Methods

add_pending_record(record, destroyed = false) click to toggle source
# File lib/kasket.rb, line 60
def self.add_pending_record(record, destroyed = false)
  Thread.current[:kasket_pending_records] ||= {}
  Thread.current[:kasket_pending_records][record] = destroyed ? nil : record
end
cache()
Alias for: cache_store
cache_store() click to toggle source
# File lib/kasket.rb, line 45
def self.cache_store
  @cache_store ||= Rails.cache
end
Also aliased as: cache
cache_store=(options) click to toggle source
# File lib/kasket.rb, line 41
def self.cache_store=(options)
  @cache_store = ActiveSupport::Cache.lookup_store(options)
end
clear_pending_records() click to toggle source
# File lib/kasket.rb, line 65
def self.clear_pending_records
  Thread.current[:kasket_pending_records] = nil
end
pending_records() click to toggle source

Keys are the records being saved. Values are either the saved record, or nil if the record has been destroyed.

# File lib/kasket.rb, line 56
def self.pending_records
  Thread.current[:kasket_pending_records]
end

Public Instance Methods

setup(options = {}) click to toggle source
# File lib/kasket.rb, line 26
def setup(options = {})
  return if ActiveRecord::Base.respond_to?(:has_kasket)

  CONFIGURATION[:max_collection_size] = options[:max_collection_size] if options[:max_collection_size]
  CONFIGURATION[:write_through]       = options[:write_through]       if options[:write_through]
  CONFIGURATION[:default_expires_in]  = options[:default_expires_in]  if options[:default_expires_in]

  ActiveRecord::Base.extend(Kasket::ConfigurationMixin)

  if defined?(ActiveRecord::Relation)
    ActiveRecord::Relation.include Kasket::RelationMixin
    Arel::SelectManager.include Kasket::SelectManagerMixin
  end
end