-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use a null object to avoid checks to @instance
In the `ConnectionManagement` class, a pattern we see a lot is the following one: ```ruby if @instance # do something else # do something else end ``` This patch aims to simplify this a bit by introducing a null object (`NullInstance`) which will be returned when `@instance` is null. This way the rest of the code doesn’t care with which object it’s working and has just to call the expected methods on it.
- Loading branch information
Showing
7 changed files
with
205 additions
and
188 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,6 @@ AllCops: | |
Exclude: | ||
- gemfiles/vendor/bundle/**/* | ||
- vendor/bundle/**/* | ||
|
||
Discourse/Plugins: | ||
Enabled: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# frozen_string_literal: true | ||
source 'https://rubygems.org' | ||
|
||
group :test do | ||
gem 'activerecord', '~> 7.1.0' | ||
gem 'railties', '~> 7.1.0' | ||
gem 'rspec' | ||
gem 'sqlite3', '~> 1.4' | ||
gem 'byebug' | ||
gem 'rubocop' | ||
gem 'rubocop-discourse' | ||
end |
Oops, something went wrong.