Module: Export::Helpers::MaterialExamined
- Defined in:
- lib/export/helpers/material_examined.rb
Class Method Summary collapse
- .build_augmentations(scope) ⇒ Object private
- .edit_link_for(dwc) ⇒ Object private
-
.render_for_otu(otu, dwc_scope: nil, order: ::Utilities::MaterialExamined::DEFAULT_ORDER, augmentations: {}) ⇒ Object
Convenience wrapper that returns rendered Markdown directly.
- .renderer_for_otu(otu, dwc_scope: nil, order: ::Utilities::MaterialExamined::DEFAULT_ORDER, augmentations: {}, todo: false) ⇒ Utilities::MaterialExamined
Class Method Details
.build_augmentations(scope) ⇒ Object (private)
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/export/helpers/material_examined.rb', line 48 private_class_method def self.build_augmentations(scope) scope.each_with_object({}) do |dwc, hash| occ_id = dwc.occurrenceID next if occ_id.blank? hash[occ_id] = { label: dwc.catalogNumber.presence, edit_link: edit_link_for(dwc) } end end |
.edit_link_for(dwc) ⇒ Object (private)
59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/export/helpers/material_examined.rb', line 59 private_class_method def self.edit_link_for(dwc) id = dwc.dwc_occurrence_object_id case dwc.dwc_occurrence_object_type when 'CollectionObject' "/tasks/accessions/comprehensive?collection_object_id=#{id}" when 'FieldOccurrence' "/tasks/field_occurrences/browse?field_occurrence_id=#{id}" when 'AssertedDistribution' "/tasks/asserted_distributions/new_asserted_distribution?asserted_distribution_id=#{id}" end end |
.render_for_otu(otu, dwc_scope: nil, order: ::Utilities::MaterialExamined::DEFAULT_ORDER, augmentations: {}) ⇒ Object
Convenience wrapper that returns rendered Markdown directly.
44 45 46 |
# File 'lib/export/helpers/material_examined.rb', line 44 def self.render_for_otu(otu, dwc_scope: nil, order: ::Utilities::MaterialExamined::DEFAULT_ORDER, augmentations: {}) renderer_for_otu(otu, dwc_scope:, order:, augmentations:, todo: false).render end |
.renderer_for_otu(otu, dwc_scope: nil, order: ::Utilities::MaterialExamined::DEFAULT_ORDER, augmentations: {}, todo: false) ⇒ Utilities::MaterialExamined
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/export/helpers/material_examined.rb', line 28 def self.renderer_for_otu(otu, dwc_scope: nil, order: ::Utilities::MaterialExamined::DEFAULT_ORDER, augmentations: {}, todo: false) scope = dwc_scope || ::DwcOccurrence.scoped_by_otu(otu) occurrences = scope.map(&:dwc_json) return ::Utilities::MaterialExamined.new([], order:, augmentations:, todo:) if occurrences.empty? merged_augmentations = build_augmentations(scope).merge(augmentations) ::Utilities::MaterialExamined.new( occurrences, order:, augmentations: merged_augmentations, todo: ) end |