Module: RailsLens::Schema::AnnotationRemoval

Included in:
AnnotationManager, DatabaseAnnotator
Defined in:
lib/rails_lens/schema/annotation_removal.rb

Overview

Shared file-based annotation removal. Host classes must provide a #model_file_path method returning the file to clean.

Instance Method Summary collapse

Instance Method Details

#remove_annotations(file_path = nil) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/rails_lens/schema/annotation_removal.rb', line 8

def remove_annotations(file_path = nil)
  file_path ||= model_file_path
  return unless file_path && File.exist?(file_path)

  content = File.read(file_path)
  cleaned_content = Annotation.remove(content)

  if cleaned_content == content
    false
  else
    File.write(file_path, cleaned_content)
    true
  end
end