Module: Gorynich

Defined in:
lib/gorynich/head/delayed_job.rb,
lib/gorynich.rb,
lib/gorynich/head.rb,
lib/gorynich/config.rb,
lib/gorynich/engine.rb,
lib/gorynich/current.rb,
lib/gorynich/fetcher.rb,
lib/gorynich/version.rb,
lib/gorynich/switcher.rb,
lib/gorynich/configuration.rb,
lib/gorynich/fetchers/file.rb,
lib/gorynich/fetchers/consul.rb,
lib/gorynich/head/active_job.rb,
lib/gorynich/head/action_cable.rb,
lib/gorynich/head/active_record.rb,
lib/gorynich/head/rack_middleware.rb,
lib/gorynich/fetchers/consul_secure.rb,
lib/generators/gorynich/install_generator.rb,
lib/generators/gorynich/gorynich_generator.rb

Overview

:nocov:

Defined Under Namespace

Modules: Fetchers, Generators, Head Classes: Config, ConfigError, Configuration, Current, Engine, Error, Fetcher, HostNotFound, Switcher, TenantNotFound, UriNotFound

Constant Summary collapse

VERSION =
'1.3.3'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configurationObject

Configuration of gem



115
116
117
# File 'lib/gorynich.rb', line 115

def configuration
  @configuration
end

Class Method Details

.configure {|configuration| ... } ⇒ Object

Setting up and initializing the gem

Yields:



129
130
131
132
133
134
135
# File 'lib/gorynich.rb', line 129

def configure
  yield(configuration)

  reload

  ::ActiveRecord::Base.include(Head::ActiveRecord)
end

.instanceGorynich::Config

App configuration

Returns:



62
63
64
# File 'lib/gorynich.rb', line 62

def instance
  @instance ||= Config.new
end

.reloadObject

Reload app configuration



52
53
54
55
# File 'lib/gorynich.rb', line 52

def reload
  @instance = Config.new
  @switcher = Switcher.new(config: instance)
end

.resetObject

Reset to default configuration settings



122
123
124
# File 'lib/gorynich.rb', line 122

def reset
  @configuration = Configuration.new
end

.switcherGorynich::Switcher

Tenant switcher

Returns:



71
72
73
# File 'lib/gorynich.rb', line 71

def switcher
  @switcher ||= Switcher.new(config: instance)
end

.with(*args, **opts, &block) ⇒ Object

Block for performing actions with a tenant database with a change in current attributes (ActiveSupport::CurrentAttributes)

Parameters:

  • tenant (String, Symbol)
  • **opts (Hash)

    options for Gorynich::Current



99
100
101
# File 'lib/gorynich.rb', line 99

def with(*args, **opts, &block)
  switcher.with(*args, **opts, &block)
end

.with_current(*args, &block) ⇒ Object

Block for performing actions with a tenant database with a change in current attributes (ActiveSupport::CurrentAttributes)

Parameters:

  • tenant (String, Symbol)


89
90
91
# File 'lib/gorynich.rb', line 89

def with_current(*args, &block)
  switcher.with_current(*args, &block)
end

.with_database(*args, &block) ⇒ Object

Block for performing actions with a tenant database

Parameters:

  • tenant (String, Symbol)


80
81
82
# File 'lib/gorynich.rb', line 80

def with_database(*args, &block)
  switcher.with_database(*args, &block)
end

.with_each_tenant(**opts, &block) ⇒ Object

Block for performing actions with each tenant database

Parameters:

  • except (Array)

    Array of tenants with which no actions will be performed



108
109
110
# File 'lib/gorynich.rb', line 108

def with_each_tenant(**opts, &block)
  switcher.with_each_tenant(**opts, &block)
end