Class: ActiveShard::ShardLookupHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/active_shard/shard_lookup_handler.rb

Overview

Handles current shard resolution using the provided scope

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ ShardLookupHandler

Initializes a shard lookup handler

Parameters:

  • options (Hash) (defaults to: {})

Options Hash (options):



12
13
14
# File 'lib/active_shard/shard_lookup_handler.rb', line 12

def initialize( options={} )
  @scope  = options[:scope]
end

Instance Method Details

#lookup_active_shard(schema_name) ⇒ Symbol?

Returns the active shard for the provided schema, or nil if none.

Parameters:

  • schema_name (Symbol)

Returns:

  • (Symbol, nil)

    shard name if any



21
22
23
# File 'lib/active_shard/shard_lookup_handler.rb', line 21

def lookup_active_shard( schema_name )
  @scope.active_shard_for_schema( schema_name )
end