Class: Spotlight::BulkUpdatesCsvTemplateService
- Inherits:
-
Object
- Object
- Spotlight::BulkUpdatesCsvTemplateService
- Defined in:
- app/services/spotlight/bulk_updates_csv_template_service.rb
Overview
A service to generate a CSV template suitable for re-uploading for bulk updates
Instance Attribute Summary collapse
-
#exhibit ⇒ Object
readonly
Returns the value of attribute exhibit.
Instance Method Summary collapse
-
#initialize(exhibit:) ⇒ BulkUpdatesCsvTemplateService
constructor
A new instance of BulkUpdatesCsvTemplateService.
- #template(view_context:, title: true, tags: true, visibility: true) {|::CSV.generate_line(csv_headers(title:, tags:, visibility:))| ... } ⇒ Object
Constructor Details
#initialize(exhibit:) ⇒ BulkUpdatesCsvTemplateService
Returns a new instance of BulkUpdatesCsvTemplateService.
10 11 12 |
# File 'app/services/spotlight/bulk_updates_csv_template_service.rb', line 10 def initialize(exhibit:) @exhibit = exhibit end |
Instance Attribute Details
#exhibit ⇒ Object (readonly)
Returns the value of attribute exhibit.
8 9 10 |
# File 'app/services/spotlight/bulk_updates_csv_template_service.rb', line 8 def exhibit @exhibit end |
Instance Method Details
#template(view_context:, title: true, tags: true, visibility: true) {|::CSV.generate_line(csv_headers(title:, tags:, visibility:))| ... } ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/services/spotlight/bulk_updates_csv_template_service.rb', line 14 def template(view_context:, title: true, tags: true, visibility: true) return to_enum(:template, view_context:, title:, tags:, visibility:) unless block_given? yield ::CSV.generate_line(csv_headers(title:, tags:, visibility:)) each_document do |document| sidecar = document.sidecar(exhibit) yield ::CSV.generate_line([ document.id, (title_column(view_context, document) if title), (visibility_column(sidecar) if visibility), ((sidecar) if ) ].flatten.compact) end end |