Class: FastExists::MultiTenant::Allocator

Inherits:
Object
  • Object
show all
Defined in:
lib/fast_exists/multi_tenant/allocator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(strategy_type = FastExists.configuration.tenant_strategy, options = {}) ⇒ Allocator

Returns a new instance of Allocator.



8
9
10
11
# File 'lib/fast_exists/multi_tenant/allocator.rb', line 8

def initialize(strategy_type = FastExists.configuration.tenant_strategy, options = {})
  @strategy_type = strategy_type.to_sym
  @strategy = build_strategy(@strategy_type, options)
end

Instance Attribute Details

#strategyObject (readonly)

Returns the value of attribute strategy.



6
7
8
# File 'lib/fast_exists/multi_tenant/allocator.rb', line 6

def strategy
  @strategy
end

Instance Method Details

#add(tenant_id, attribute, value) ⇒ Object



13
14
15
# File 'lib/fast_exists/multi_tenant/allocator.rb', line 13

def add(tenant_id, attribute, value)
  @strategy.add(tenant_id, attribute, value)
end

#contains?(tenant_id, attribute, value) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/fast_exists/multi_tenant/allocator.rb', line 17

def contains?(tenant_id, attribute, value)
  @strategy.contains?(tenant_id, attribute, value)
end

#statsObject



21
22
23
# File 'lib/fast_exists/multi_tenant/allocator.rb', line 21

def stats
  @strategy.stats.merge(strategy_type: @strategy_type)
end