Class: NeonPostgres::DocumentSanitizer
- Inherits:
-
Object
- Object
- NeonPostgres::DocumentSanitizer
- Defined in:
- lib/neon_postgres/document_sanitizer.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(database_connection:, document:) ⇒ DocumentSanitizer
constructor
A new instance of DocumentSanitizer.
- #sanitize ⇒ Object
Constructor Details
#initialize(database_connection:, document:) ⇒ DocumentSanitizer
Returns a new instance of DocumentSanitizer.
15 16 17 18 |
# File 'lib/neon_postgres/document_sanitizer.rb', line 15 def initialize(database_connection:, document:) @database_connection = database_connection @document = document end |
Class Method Details
.sanitize(document:, database_connection: NeonPostgres::Database.connection) ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/neon_postgres/document_sanitizer.rb', line 6 def self.sanitize( document:, database_connection: NeonPostgres::Database.connection ) new( database_connection: database_connection, document: document ).sanitize end |
Instance Method Details
#sanitize ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/neon_postgres/document_sanitizer.rb', line 20 def sanitize values = documents_connection.find(id: document.fetch(:id)).first filename = "#{Faker::Internet.uuid}.pdf" values[:filename] = filename values[:gcp_url] = "https://neon-law-staging-private-assets.storage."\ "googleapis.com/matters/#{Faker::Internet.uuid}/#{filename}" documents_connection.insert_conflict( target: :id, update: { filename: Sequel[:excluded][:filename], gcp_url: Sequel[:excluded][:gcp_url] } ).insert(values) end |