Module: Kasket
- Defined in:
- lib/kasket.rb,
lib/kasket/version.rb,
lib/kasket/visitor.rb,
lib/kasket/read_mixin.rb,
lib/kasket/dirty_mixin.rb,
lib/kasket/write_mixin.rb,
lib/kasket/query_parser.rb,
lib/kasket/relation_mixin.rb,
lib/kasket/configuration_mixin.rb,
lib/kasket/select_manager_mixin.rb
Defined Under Namespace
Modules: ConfigurationMixin, DirtyMixin, ReadMixin, RelationMixin, SelectManagerMixin, WriteMixin
Classes: QueryParser, Version, Visitor
Constant Summary
collapse
- CONFIGURATION =
rubocop:disable Style/MutableConstant
{
max_collection_size: 100,
write_through: false,
default_expires_in: nil
}
- VERSION =
'4.11.0'
Class Method Summary
collapse
Class Method Details
.add_pending_record(record, destroyed = false) ⇒ Object
57
58
59
60
|
# File 'lib/kasket.rb', line 57
def self.add_pending_record(record, destroyed = false)
Thread.current[:kasket_pending_records] ||= {}
Thread.current[:kasket_pending_records][record] = destroyed ? nil : record
end
|
.cache_store ⇒ Object
Also known as:
cache
42
43
44
|
# File 'lib/kasket.rb', line 42
def self.cache_store
@cache_store ||= Rails.cache
end
|
.cache_store=(options) ⇒ Object
38
39
40
|
# File 'lib/kasket.rb', line 38
def self.cache_store=(options)
@cache_store = ActiveSupport::Cache.lookup_store(options)
end
|
.clear_pending_records ⇒ Object
62
63
64
|
# File 'lib/kasket.rb', line 62
def self.clear_pending_records
Thread.current[:kasket_pending_records] = nil
end
|
.pending_records ⇒ Object
Keys are the records being saved. Values are either the saved record, or nil if the record has been destroyed.
53
54
55
|
# File 'lib/kasket.rb', line 53
def self.pending_records
Thread.current[:kasket_pending_records]
end
|
.setup(options = {}) ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
|
# 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)
ActiveRecord::Relation.include(Kasket::RelationMixin)
Arel::SelectManager.include(Kasket::SelectManagerMixin)
end
|