Module: Kasket
- Defined in:
- lib/kasket.rb,
lib/kasket/events.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, Events, ReadMixin, RelationMixin, SelectManagerMixin, WriteMixin Classes: QueryParser, Version, Visitor
Constant Summary collapse
- CONFIGURATION =
rubocop:disable Style/MutableConstant
{ # rubocop:disable Style/MutableConstant max_collection_size: 100, write_through: false, default_expires_in: nil, events_callback: nil, }
- VERSION =
'4.14.1'
Class Method Summary collapse
- .add_pending_record(record, destroyed = false) ⇒ Object
- .cache_store ⇒ Object (also: cache)
- .cache_store=(options) ⇒ Object
- .clear_pending_records ⇒ Object
-
.pending_records ⇒ Object
Keys are the records being saved.
-
.setup(options = {}) ⇒ Object
Configure Kasket.
Class Method Details
.add_pending_record(record, destroyed = false) ⇒ Object
71 72 73 74 |
# File 'lib/kasket.rb', line 71 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
56 57 58 |
# File 'lib/kasket.rb', line 56 def self.cache_store @cache_store ||= Rails.cache end |
.cache_store=(options) ⇒ Object
52 53 54 |
# File 'lib/kasket.rb', line 52 def self.cache_store=() @cache_store = ActiveSupport::Cache.lookup_store() end |
.clear_pending_records ⇒ Object
76 77 78 |
# File 'lib/kasket.rb', line 76 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.
67 68 69 |
# File 'lib/kasket.rb', line 67 def self.pending_records Thread.current[:kasket_pending_records] end |
.setup(options = {}) ⇒ Object
Configure Kasket.
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/kasket.rb', line 39 def setup( = {}) return if ActiveRecord::Base.respond_to?(:has_kasket) CONFIGURATION[:max_collection_size] = [:max_collection_size] if [:max_collection_size] CONFIGURATION[:write_through] = [:write_through] if [:write_through] CONFIGURATION[:default_expires_in] = [:default_expires_in] if [:default_expires_in] CONFIGURATION[:events_callback] = [:events_callback] if [:events_callback] ActiveRecord::Base.extend(Kasket::ConfigurationMixin) ActiveRecord::Relation.include(Kasket::RelationMixin) Arel::SelectManager.include(Kasket::SelectManagerMixin) end |