Sha256: 014b21a4af6747f25afdcab0a24d14073c9178f99733749f6d0a68d796a404e8

Contents?: true

Size: 702 Bytes

Versions: 62

Compression:

Stored size: 702 Bytes

Contents

module Switchman::Rails
  module ClassMethods
    def cache
      Switchman::Shard.current.database_server.cache_store
    end
  end

  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
end

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
switchman-1.3.18 lib/switchman/rails.rb
switchman-1.3.17 lib/switchman/rails.rb
switchman-1.3.14.pre.1 lib/switchman/rails.rb
switchman-1.3.13.pre.1 lib/switchman/rails.rb
switchman-1.3.16 lib/switchman/rails.rb
switchman-1.3.15 lib/switchman/rails.rb
switchman-1.3.14 lib/switchman/rails.rb
switchman-1.3.13 lib/switchman/rails.rb
switchman-1.3.12 lib/switchman/rails.rb
switchman-1.3.11 lib/switchman/rails.rb
switchman-1.3.10 lib/switchman/rails.rb
switchman-1.3.9 lib/switchman/rails.rb
switchman-1.3.8 lib/switchman/rails.rb
switchman-1.3.7 lib/switchman/rails.rb
switchman-1.3.6 lib/switchman/rails.rb
switchman-1.3.5 lib/switchman/rails.rb
switchman-1.3.4 lib/switchman/rails.rb
switchman-1.3.3 lib/switchman/rails.rb
switchman-1.3.2 lib/switchman/rails.rb
switchman-1.3.1 lib/switchman/rails.rb