Class: Localtower::Generators::ServiceObjects::InsertNullable
- Inherits:
-
Object
- Object
- Localtower::Generators::ServiceObjects::InsertNullable
- Defined in:
- lib/localtower/generators/service_objects/insert_nullable.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(attributes) ⇒ InsertNullable
constructor
A new instance of InsertNullable.
Constructor Details
#initialize(attributes) ⇒ InsertNullable
Returns a new instance of InsertNullable.
5 6 7 |
# File 'lib/localtower/generators/service_objects/insert_nullable.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_nullable.rb', line 9 def call attributes.each do |attribute| line_str = File.read(Localtower::Tools.last_migration).match(/((.*)t\.(.*)\:#{attribute})/)[0] content = File.read(Localtower::Tools.last_migration).gsub(line_str, "#{line_str}, null: false") File.write(Localtower::Tools.last_migration, content) end end |