Sha256: 91cd6f4f4fed3a6b84bf3411af185ad3650e37ced67c763861bec2f78d0af8ff
Contents?: true
Size: 1.12 KB
Versions: 2
Compression:
Stored size: 1.12 KB
Contents
module Localtower module Generators module ServiceObjects class InsertForeignKeys def initialize(attributes) @attributes = attributes end def call attributes.each do |attribute| attribute.each do |attr_key, options| line_str = Localtower::Tools.line_for_attribute(attr_key)[0] if line_str.present? if options['foreign_key'].present? if line_str['foreign_key: true'] content = File.read(Localtower::Tools.last_migration_pending) else content = File.read(Localtower::Tools.last_migration_pending).gsub(line_str, "#{line_str}, foreign_key: true") end else content = File.read(Localtower::Tools.last_migration_pending).gsub(line_str, line_str.gsub(', foreign_key: true', '')) end File.write(Localtower::Tools.last_migration_pending, content) end end end end private attr_reader :attributes end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
localtower-2.0.1 | lib/localtower/generators/service_objects/insert_foreign_keys.rb |
localtower-2.0.0 | lib/localtower/generators/service_objects/insert_foreign_keys.rb |