Class: Mobility::BackendResetter
- Defined in:
- lib/mobility/backend_resetter.rb
Overview
Resets backend cache when reset events occur.
Direct Known Subclasses
Class Method Summary collapse
-
.for(model_class) ⇒ Object
Returns backend resetter class for model class.
Instance Method Summary collapse
-
#initialize(attributes) { ... } ⇒ BackendResetter
constructor
A new instance of BackendResetter.
Constructor Details
#initialize(attributes) { ... } ⇒ BackendResetter
Returns a new instance of BackendResetter.
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/mobility/backend_resetter.rb', line 19 def initialize(attributes, &block) raise ArgumentError, "block required" unless block_given? @model_reset_method = Proc.new do attributes.each do |attribute| if @mobility_backends && @mobility_backends[attribute] @mobility_backends[attribute].instance_eval &block end end end end |
Class Method Details
.for(model_class) ⇒ Object
Returns backend resetter class for model class
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/mobility/backend_resetter.rb', line 32 def self.for(model_class) if Loaded::ActiveRecord && model_class < ::ActiveRecord::Base ActiveRecord::BackendResetter elsif Loaded::ActiveRecord && model_class.ancestors.include?(::ActiveModel::Dirty) ActiveModel::BackendResetter elsif Loaded::Sequel && model_class < ::Sequel::Model Sequel::BackendResetter else self end end |