Sha256: 816f63279afec06f85dfe09c66544af3cf65f1f74984770a4706d438f4832ee4

Contents?: true

Size: 1.14 KB

Versions: 22

Compression:

Stored size: 1.14 KB

Contents

# frozen_string_literal: true

require 'switchman/database_server'

module Switchman
  class DefaultShard
    def id; 'default'; end
    alias cache_key id
    def activate(*categories); yield; end
    def activate!(*categories); end
    def default?; true; end
    def primary?; true; end
    def relative_id_for(local_id, target = nil); local_id; end
    def global_id_for(local_id); local_id; end
    def database_server_id; nil; end
    def database_server; DatabaseServer.find(nil); end
    def new_record?; false; end
    def name
      unless instance_variable_defined?(:@name)
        @name = nil # prevent taking this branch on recursion
        @name = database_server.shard_name(:bootstrap)
      end
      @name
    end
    def description; ::Rails.env; end
    # The default's shard is always the default shard
    def shard; self; end
    def _dump(depth)
      ''
    end
    def self._load(str)
      Shard.default
    end

    def ==(rhs)
      return true if rhs.is_a?(DefaultShard) || (rhs.is_a?(Shard) && rhs[:default])
      super
    end

    class << self
      def instance
        @instance ||= new
      end

      private :new
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
switchman-2.2.3 lib/switchman/default_shard.rb
switchman-2.2.2 lib/switchman/default_shard.rb
switchman-2.2.1 lib/switchman/default_shard.rb
switchman-2.2.0 lib/switchman/default_shard.rb
switchman-2.1.6 lib/switchman/default_shard.rb
switchman-2.1.5 lib/switchman/default_shard.rb
switchman-2.1.4 lib/switchman/default_shard.rb
switchman-2.1.3 lib/switchman/default_shard.rb
switchman-2.1.2 lib/switchman/default_shard.rb
switchman-2.1.1 lib/switchman/default_shard.rb
switchman-2.1.0 lib/switchman/default_shard.rb
switchman-2.0.13 lib/switchman/default_shard.rb
switchman-2.0.12 lib/switchman/default_shard.rb
switchman-2.0.11 lib/switchman/default_shard.rb
switchman-2.0.10 lib/switchman/default_shard.rb
switchman-2.0.9 lib/switchman/default_shard.rb
switchman-2.0.8 lib/switchman/default_shard.rb
switchman-2.0.7 lib/switchman/default_shard.rb
switchman-2.0.6 lib/switchman/default_shard.rb
switchman-2.0.5 lib/switchman/default_shard.rb