Skip to content

Commit

Permalink
Merge 617d0a7 into 828bcc4
Browse files Browse the repository at this point in the history
  • Loading branch information
flyerhzm committed Mar 16, 2021
2 parents 828bcc4 + 617d0a7 commit 1f7496d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions lib/rails/convert_active_record_dirty_5_0_to_5_1.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ def call_after_create
# after_save :invalidate_cache, if: :status_changed?
with_node type: 'sym', to_value: before_name do
if before_name.is_a?(Regexp)
if node.to_value =~ before_name && attributes.include?($1)
replace_with ":#{after_name.sub('{{attribute}}', $1)}"
if node.to_value =~ before_name && attributes.include?(Regexp.last_match(1))
replace_with ":#{after_name.sub('{{attribute}}', Regexp.last_match(1))}"
end
else
replace_with after_name
Expand All @@ -102,8 +102,8 @@ def call_after_create
# end
with_node type: 'send', message: before_name do
if before_name.is_a?(Regexp)
if node.message.to_s =~ before_name && attributes.include?($1)
replace_with add_receiver_if_necessary(after_name.sub('{{attribute}}', $1))
if node.message.to_s =~ before_name && attributes.include?(Regexp.last_match(1))
replace_with add_receiver_if_necessary(after_name.sub('{{attribute}}', Regexp.last_match(1)))
end
else
replace_with add_receiver_if_necessary(after_name)
Expand Down
4 changes: 2 additions & 2 deletions lib/ruby/new_2_2_hash_syntax.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
when :sym
case node.key.to_source
when /\A:"([^"'\\]*)"\z/
replace_with "'#{$1}': {{value}}"
replace_with "'#{Regexp.last_match(1)}': {{value}}"
when /\A:(.+)\z/
replace_with "#{$1}: {{value}}"
replace_with "#{Regexp.last_match(1)}: {{value}}"
end
when :dsym
if new_key = node.key.to_source[/\A:(.+)/, 1]
Expand Down

0 comments on commit 1f7496d

Please sign in to comment.