1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Fix error in deprecation

When I implemented the deprecation for #38536 I left in the setter in
the initalizer. This meant that objects returned had both `@name` and
`@spec_name` set and objects looked like this:

```
<ActiveRecord::DatabaseConfigurations::HashConfig:0x00007fe0f7100c68
  @env_name="development",
  @name="primary",
  @spec_name="primary",
  @config={
    :adapter=>"mysql2",
    :database=>"recipes_app_development"
  }
>
```

Since we don't use the kwarg to create the hash config and we have the
reader for reading off the object or selecting from the configurations
objects list we can remove this so the object looks like:

```
<ActiveRecord::DatabaseConfigurations::HashConfig:0x00007fe0f7100c68
  @env_name="development",
  @name="primary",
  @config={
    :adapter=>"mysql2",
    :database=>"recipes_app_development"
  }
>
```
This commit is contained in:
eileencodes 2020-02-28 17:00:45 -05:00
parent df74da026b
commit 13e28f5f55
No known key found for this signature in database
GPG key ID: BA5C575120BBE8DF

View file

@ -6,17 +6,20 @@ module ActiveRecord
# UrlConfig respectively. It will never return a DatabaseConfig object, # UrlConfig respectively. It will never return a DatabaseConfig object,
# as this is the parent class for the types of database configuration objects. # as this is the parent class for the types of database configuration objects.
class DatabaseConfig # :nodoc: class DatabaseConfig # :nodoc:
attr_reader :env_name, :name, :spec_name attr_reader :env_name, :name
deprecate spec_name: "please use name instead"
attr_accessor :owner_name attr_accessor :owner_name
def initialize(env_name, name) def initialize(env_name, name)
@env_name = env_name @env_name = env_name
@name = name @name = name
@spec_name = name
end end
def spec_name
@name
end
deprecate spec_name: "please use name instead"
def config def config
raise NotImplementedError raise NotImplementedError
end end