lib/synvert/snippets/rails/convert_dynamic_finders.rb in synvert-0.0.7 vs lib/synvert/snippets/rails/convert_dynamic_finders.rb in synvert-0.0.8
- old
+ new
@@ -6,50 +6,50 @@
}.join(", ")
end
within_files '**/*.rb' do
# find_all_by_... => where(...)
- with_node type: 'send', message: /find_all_by_(.*)/ do
+ with_node type: 'send', message: /find_all_by_/ do
hash_params = dynamic_finder_to_hash("find_all_by_")
replace_with "{{receiver}}.where(#{hash_params})"
end
end
within_files '**/*.rb' do
# find_by_... => where(...).first
- with_node type: 'send', message: /find_by_(.*)/ do
+ with_node type: 'send', message: /find_by_/ do
hash_params = dynamic_finder_to_hash("find_by_")
replace_with "{{receiver}}.where(#{hash_params}).first"
end
end
within_files '**/*.rb' do
# find_last_by_... => where(...).last
- with_node type: 'send', message: /find_last_by_(.*)/ do
+ with_node type: 'send', message: /find_last_by_/ do
hash_params = dynamic_finder_to_hash("find_last_by_")
replace_with "{{receiver}}.where(#{hash_params}).last"
end
end
within_files '**/*.rb' do
# scoped_by_... => where(...)
- with_node type: 'send', message: /scoped_by_(.*)/ do
+ with_node type: 'send', message: /scoped_by_/ do
hash_params = dynamic_finder_to_hash("scoped_by_")
replace_with "{{receiver}}.where(#{hash_params})"
end
end
within_files '**/*.rb' do
# find_or_initialize_by_... => find_or_initialize_by(...)
- with_node type: 'send', message: /find_or_initialize_by_(.*)/ do
+ with_node type: 'send', message: /find_or_initialize_by_/ do
hash_params = dynamic_finder_to_hash("find_or_initialize_by_")
replace_with "{{receiver}}.find_or_initialize_by(#{hash_params})"
end
end
within_files '**/*.rb' do
# find_or_create_by_... => find_or_create_by(...)
- with_node type: 'send', message: /find_or_create_by_(.*)/ do
+ with_node type: 'send', message: /find_or_create_by_/ do
hash_params = dynamic_finder_to_hash("find_or_create_by_")
replace_with "{{receiver}}.find_or_create_by(#{hash_params})"
end
end
end