Skip to content

Commit

Permalink
Merge pull request #39 from B-CDD/chore/remove-singleton-stdlib
Browse files Browse the repository at this point in the history
Remove usage of singleton (stdlib)
  • Loading branch information
serradura committed Mar 16, 2024
2 parents 64bab97 + ac39b10 commit 20a7dd2
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Steepfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ target :lib do
# check 'app/models/**/*.rb' # Glob
# ignore 'lib/templates/*.rb'

library 'singleton' # Standard libraries
# library 'singleton' # Standard libraries
# library 'strong_json' # Gems

# configure_code_diagnostics(D::Ruby.default) # `default` diagnostics setting (applies by default)
Expand Down
1 change: 0 additions & 1 deletion lib/bcdd/result.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# frozen_string_literal: true

require 'set'
require 'singleton'

module BCDD
require_relative 'success'
Expand Down
6 changes: 4 additions & 2 deletions lib/bcdd/result/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@

class BCDD::Result
class Config
include ::Singleton

attr_reader :addon, :feature, :constant_alias, :pattern_matching

def initialize
Expand Down Expand Up @@ -58,5 +56,9 @@ def inspect
"options=#{options.keys.sort.inspect} " \
"and_then!=#{and_then!.options.inspect}>"
end

@instance = new

singleton_class.send(:attr_reader, :instance)
end
end
6 changes: 4 additions & 2 deletions lib/bcdd/result/transitions/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

module BCDD::Result::Transitions
class Config
include ::Singleton

attr_reader :listener, :trace_id

def initialize
Expand All @@ -22,5 +20,9 @@ def trace_id=(arg)

@trace_id = arg
end

@instance = new

singleton_class.send(:attr_reader, :instance)
end
end
2 changes: 0 additions & 2 deletions sig/bcdd/result/config.rbs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
class BCDD::Result::Config
include Singleton

ADDON: Hash[Symbol, Hash[Symbol, untyped]]
FEATURE: Hash[Symbol, Hash[Symbol, untyped]]
PATTERN_MATCHING: Hash[Symbol, Hash[Symbol, untyped]]
Expand Down
2 changes: 0 additions & 2 deletions sig/bcdd/result/transitions.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ class BCDD::Result
end

class Config
include ::Singleton

attr_reader listener: untyped
attr_reader trace_id: ::Proc

Expand Down
2 changes: 1 addition & 1 deletion test/bcdd/result/config_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class BCDD::Result::Config
class Test < Minitest::Test
test '.instance' do
assert BCDD::Result::Config.instance.is_a?(Singleton)
assert BCDD::Result::Config.instance.is_a?(BCDD::Result::Config)

assert_same(BCDD::Result::Config.instance, BCDD::Result.config)
end
Expand Down

0 comments on commit 20a7dd2

Please sign in to comment.