Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#151] removed reloader and console overwrite of reload method #174

Merged
merged 1 commit into from
Nov 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ RSpec/DescribedClass:
- 'spec/tenant_spec.rb'
- 'spec/unit/elevators/host_hash_spec.rb'
- 'spec/unit/migrator_spec.rb'
- 'spec/unit/reloader_spec.rb'

# Offense count: 5
# Cop supports --auto-correct.
Expand Down Expand Up @@ -128,7 +127,6 @@ RSpec/FilePath:
- 'spec/unit/elevators/host_spec.rb'
- 'spec/unit/elevators/subdomain_spec.rb'
- 'spec/unit/migrator_spec.rb'
- 'spec/unit/reloader_spec.rb'

# Offense count: 1
# Cop supports --auto-correct.
Expand Down Expand Up @@ -159,7 +157,6 @@ RSpec/InstanceVariable:
# Cop supports --auto-correct.
RSpec/LeadingSubject:
Exclude:
- 'spec/unit/reloader_spec.rb'

# Offense count: 2
RSpec/LeakyConstantDeclaration:
Expand Down Expand Up @@ -196,7 +193,6 @@ RSpec/NamedSubject:
- 'spec/support/contexts.rb'
- 'spec/support/requirements.rb'
- 'spec/tenant_spec.rb'
- 'spec/unit/reloader_spec.rb'

# Offense count: 24
RSpec/NestedGroups:
Expand All @@ -217,7 +213,6 @@ RSpec/VerifiedDoubles:
Exclude:
- 'spec/integration/apartment_rake_integration_spec.rb'
- 'spec/unit/elevators/first_subdomain_spec.rb'
- 'spec/unit/reloader_spec.rb'

# Offense count: 17
Style/Documentation:
Expand All @@ -233,7 +228,6 @@ Style/Documentation:
- 'lib/apartment/migrator.rb'
- 'lib/apartment/model.rb'
- 'lib/apartment/railtie.rb'
- 'lib/apartment/reloader.rb'
- 'lib/apartment/tasks/enhancements.rb'
- 'lib/apartment/tasks/task_helper.rb'
- 'lib/generators/apartment/install/install_generator.rb'
16 changes: 0 additions & 16 deletions lib/apartment/console.rb
Original file line number Diff line number Diff line change
@@ -1,21 +1,5 @@
# frozen_string_literal: true

# A workaround to get `reload!` to also call Apartment::Tenant.init
# This is unfortunate, but I haven't figured out how to hook into the reload process *after* files are reloaded

# reloads the environment
# rubocop:disable Style/OptionalBooleanParameter
def reload!(print = true)
puts 'Reloading...' if print

# This triggers the to_prepare callbacks
ActionDispatch::Callbacks.new(proc {}).call({})
# Manually init Apartment again once classes are reloaded
Apartment::Tenant.init
true
end
# rubocop:enable Style/OptionalBooleanParameter

def st(schema_name = nil)
if schema_name.nil?
tenant_list.each { |t| puts t }
Expand Down
19 changes: 0 additions & 19 deletions lib/apartment/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

require 'rails'
require 'apartment/tenant'
require 'apartment/reloader'

module Apartment
class Railtie < Rails::Railtie
Expand Down Expand Up @@ -60,23 +59,5 @@ class Railtie < Rails::Railtie
load 'tasks/apartment.rake'
require 'apartment/tasks/enhancements' if Apartment.db_migrate_tenants
end

#
# The following initializers are a workaround to the fact that I can't properly hook into the rails reloader
# Note this is technically valid for any environment where cache_classes is false, for us, it's just development
#
if Rails.env.development?

# Apartment::Reloader is middleware to initialize things properly on each request to dev
initializer 'apartment.init' do |app|
app.config.middleware.use Apartment::Reloader
end

# Overrides reload! to also call Apartment::Tenant.init as well
# so that the reloaded classes have the proper table_names
console do
require 'apartment/console'
end
end
end
end
22 changes: 0 additions & 22 deletions lib/apartment/reloader.rb

This file was deleted.

24 changes: 0 additions & 24 deletions spec/unit/reloader_spec.rb

This file was deleted.