Class: AtlasEngine::IndexConfigurationFactory

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
app/models/atlas_engine/index_configuration_factory.rb

Constant Summary collapse

IndexConfigurations =
T.type_alias { T::Hash[T.any(String, Symbol), T.untyped] }
INDEX_CONFIGURATIONS_ROOT =
T.let(
  File.join(AtlasEngine::Engine.root, "db/data/address_synonyms/index_configurations"), String
)
COUNTRIES_ROOT =
T.let(File.join(AtlasEngine::Engine.root, "app/countries/atlas_engine"), String)
DEFAULT_NUMBER_OF_SHARDS =
1
DEFAULT_NUMBER_OF_REPLICAS =
1
DEFAULT_MIN_ZIP_EDGE_GRAM =
1
DEFAULT_MAX_ZIP_EDGE_GRAM =
10

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(country_code:, locale: nil, shard_override: nil, replica_override: nil) ⇒ IndexConfigurationFactory

Returns a new instance of IndexConfigurationFactory.



43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'app/models/atlas_engine/index_configuration_factory.rb', line 43

def initialize(
  country_code:,
  locale: nil,
  shard_override: nil,
  replica_override: nil
)
  @country_code = T.let(country_code.downcase.to_sym, Symbol)
  @locale = T.let(locale.present? ? locale.downcase : nil, T.nilable(String))
  @country = T.let(Worldwide.region(code: @country_code), Worldwide::Region)
  @country_profile = T.let(CountryProfile.for(@country_code.to_s.upcase, @locale), CountryProfile)
  @shard_override = T.let(shard_override, T.nilable(Integer))
  @replica_override = T.let(replica_override, T.nilable(Integer))
end

Instance Attribute Details

#country_codeObject (readonly)

Returns the value of attribute country_code.



21
22
23
# File 'app/models/atlas_engine/index_configuration_factory.rb', line 21

def country_code
  @country_code
end

#country_profileObject (readonly)

Returns the value of attribute country_profile.



27
28
29
# File 'app/models/atlas_engine/index_configuration_factory.rb', line 27

def country_profile
  @country_profile
end

#localeObject (readonly)

Returns the value of attribute locale.



24
25
26
# File 'app/models/atlas_engine/index_configuration_factory.rb', line 24

def locale
  @locale
end

#replica_overrideObject (readonly)

Returns the value of attribute replica_override.



33
34
35
# File 'app/models/atlas_engine/index_configuration_factory.rb', line 33

def replica_override
  @replica_override
end

#shard_overrideObject (readonly)

Returns the value of attribute shard_override.



30
31
32
# File 'app/models/atlas_engine/index_configuration_factory.rb', line 30

def shard_override
  @shard_override
end

Instance Method Details

#index_configuration(creating: false) ⇒ Object



62
63
64
65
# File 'app/models/atlas_engine/index_configuration_factory.rb', line 62

def index_configuration(creating: false)
  remove_create_only_settings unless creating
  configuration
end