Class: Localtower::Generators::ServiceObjects::InsertArray
- Inherits:
-
Object
- Object
- Localtower::Generators::ServiceObjects::InsertArray
- Defined in:
- lib/localtower/generators/service_objects/insert_array.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(attributes) ⇒ InsertArray
constructor
A new instance of InsertArray.
Constructor Details
#initialize(attributes) ⇒ InsertArray
Returns a new instance of InsertArray.
5 6 7 |
# File 'lib/localtower/generators/service_objects/insert_array.rb', line 5 def initialize(attributes) @attributes = attributes end |
Instance Method Details
#call ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/localtower/generators/service_objects/insert_array.rb', line 9 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) end end |