Module: Switchman::Rails

Defined in:
lib/switchman/rails.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/switchman/rails.rb', line 8

def self.included(klass)
  klass.extend(ClassMethods)
  klass.singleton_class.send(:remove_method, :cache)

  # in Rails 4+, the Rails.cache= method was used during bootstrap to set
  # Rails.cache(_without_sharding) to the value from the config file. but now
  # that that's done (the bootstrap happened before this module is included
  # into Rails), we want to make sure no one tries to assign to Rails.cache,
  # because it would be wrong w.r.t. sharding.
  klass.singleton_class.send(:remove_method, :cache=) if ::Rails.version >= '4'
end