-
-
Notifications
You must be signed in to change notification settings - Fork 31
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
Refactor RubyFileWriter #222
Changes from 10 commits
f1b4a22
cc2fcba
baec875
e217185
56c9454
9d6b422
9fcdcd5
ca91a21
d409792
486b85a
de12958
e026da5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,17 +17,13 @@ def initialize(fs:, inflector:, out: $stdout) | |
|
||
# @since 2.2.0 | ||
# @api private | ||
def call(_app_namespace, name, slice, **_opts) | ||
normalized_name = inflector.underscore(name) | ||
ensure_valid_name(normalized_name) | ||
def call(namespace:, key:, base_path:, **_opts) | ||
_namespace = namespace | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the reason for this extra assignment? It doesn't look like we use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, it was to appease Rubocop, but clearly the better move is to just remove the |
||
name = inflector.underscore(key) | ||
ensure_valid_name(name) | ||
|
||
base = if slice | ||
fs.join("slices", slice, "config", "db", "migrate") | ||
else | ||
fs.join("config", "db", "migrate") | ||
end | ||
|
||
path = fs.join(base, file_name(normalized_name)) | ||
base_path = "" if base_path == "app" # Migrations are in root dir, not app/ | ||
path = fs.join(base_path, "config", "db", "migrate", file_name(name)) | ||
|
||
fs.write(path, FILE_CONTENTS) | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just checking: by reassigning
name
here, that new value will still be passed up to the superclass method via the no-args version ofsuper
below?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup! Which I wasn't expecting. I wrote it explicitly as
super(name: name, **opts)
, but my Rubocop autocorrect got rid of it since it's equivalent tosuper
.