Skip to content

Commit de2ee25

Browse files
committed
Adapter name is class specific
There is no need to pass adapter name to the constructor.
1 parent 13ec442 commit de2ee25

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

ruby_event_store-active_record/lib/ruby_event_store/active_record/generators/database_adapter.rb

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ class DatabaseAdapter
1111
class PostgreSQL < self
1212
SUPPORTED_DATA_TYPES = %w[binary json jsonb].freeze
1313

14-
def initialize(data_type = NOT_SET)
15-
super("postgresql", data_type)
14+
def adapter_name
15+
"postgresql"
1616
end
1717

1818
def template_directory
@@ -23,8 +23,8 @@ def template_directory
2323
class MySQL < self
2424
SUPPORTED_DATA_TYPES = %w[binary json].freeze
2525

26-
def initialize(data_type = NOT_SET)
27-
super("mysql2", data_type)
26+
def adapter_name
27+
"mysql2"
2828
end
2929

3030
def template_directory
@@ -35,21 +35,20 @@ def template_directory
3535
class SQLite < self
3636
SUPPORTED_DATA_TYPES = %w[binary].freeze
3737

38-
def initialize(data_type = NOT_SET)
39-
super("sqlite", data_type)
38+
def adapter_name
39+
"sqlite"
4040
end
4141
end
4242

43-
def initialize(adapter_name, data_type)
43+
def initialize(data_type = NOT_SET)
4444
raise UnsupportedAdapter if instance_of?(DatabaseAdapter)
4545

4646
validate_data_type!(data_type)
4747

48-
@adapter_name = adapter_name
4948
@data_type = data_type
5049
end
5150

52-
attr_reader :adapter_name, :data_type
51+
attr_reader :data_type
5352

5453
def supported_data_types
5554
self.class::SUPPORTED_DATA_TYPES

ruby_event_store-active_record/spec/database_adapter_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ module ActiveRecord
5252
end
5353

5454
specify "don't allow instance of parent class directly" do
55-
expect { DatabaseAdapter.new("postgresql", "jsonb") }.to raise_error(UnsupportedAdapter)
55+
expect { DatabaseAdapter.new("jsonb") }.to raise_error(UnsupportedAdapter)
5656
end
5757

5858
specify "template directory" do

0 commit comments

Comments
 (0)