lib/localtower/generators/service_objects/insert_array.rb in localtower-1.0.0 vs lib/localtower/generators/service_objects/insert_array.rb in localtower-2.0.0
- old
+ new
@@ -6,12 +6,14 @@
@attributes = attributes
end
def call
attributes.each do |attribute|
- line_str = File.read(Localtower::Tools.last_migration).match(/((.*)t\.string :#{attribute})/)[0]
- content = File.read(Localtower::Tools.last_migration).gsub(line_str, "#{line_str}, array: true")
- File.write(Localtower::Tools.last_migration, content)
+ line_str = Localtower::Tools.line_for_attribute(attribute)[0]
+ if line_str.present?
+ content = File.read(Localtower::Tools.last_migration_pending).gsub(line_str, "#{line_str}, array: true")
+ File.write(Localtower::Tools.last_migration_pending, content)
+ end
end
end
private