Files
grecia/app/models/concerns/json_exporter.rb
Javi Martín 5ec7f4a339 Add and apply FileRead and FileWrite rubocop rules
They were added in Rubocop 1.24.0.

Even if we were already applying FileRead everywhere, this is something
we've manually fixed in the past. Another reason to add it is that these
rules are deeply related.
2022-10-19 14:26:49 +02:00

22 lines
493 B
Ruby

module JsonExporter
def to_json_file(filename)
data = []
model.find_each { |record| data << json_values(record) }
File.write(filename, data.to_json)
end
private
def strip_tags(html_string)
ActionView::Base.full_sanitizer.sanitize(html_string)
end
def model
raise "This method must be implemented in class #{self.class.name}"
end
def json_values(record)
raise "This method must be implemented in class #{self.class.name}"
end
end