Class: GeoblacklightAdmin::ImageService
- Inherits:
-
Object
- Object
- GeoblacklightAdmin::ImageService
- Defined in:
- app/services/geoblacklight_admin/image_service.rb,
app/services/geoblacklight_admin/image_service/tms.rb,
app/services/geoblacklight_admin/image_service/wms.rb,
app/services/geoblacklight_admin/image_service/iiif.rb,
app/services/geoblacklight_admin/image_service/iiif_manifest.rb,
app/services/geoblacklight_admin/image_service/image_map_layer.rb,
app/services/geoblacklight_admin/image_service/tiled_map_layer.rb,
app/services/geoblacklight_admin/image_service/dynamic_map_layer.rb
Defined Under Namespace
Modules: DynamicMapLayer, Iiif, IiifManifest, ImageMapLayer, TiledMapLayer, Tms, Wms
Instance Attribute Summary collapse
-
#document ⇒ Object
readonly
Returns the value of attribute document.
-
#logger ⇒ Object
writeonly
Sets the attribute logger.
-
#metadata ⇒ Object
writeonly
Sets the attribute metadata.
Instance Method Summary collapse
-
#initialize(document) ⇒ ImageService
constructor
A new instance of ImageService.
-
#store ⇒ Boolean
Stores the document’s image in ActiveStorage.
Constructor Details
#initialize(document) ⇒ ImageService
Returns a new instance of ImageService.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/services/geoblacklight_admin/image_service.rb', line 10 def initialize(document) @document = document # State Machine @metadata = {} @metadata["solr_doc_id"] = document.id @metadata["placeheld"] = false @document.thumbnail_state_machine.transition_to!(:processing, @metadata) # Logger @logger ||= ActiveSupport::TaggedLogging.new( Logger.new( Rails.root.join("log", "image_service_#{Rails.env}.log") ) ) end |
Instance Attribute Details
#document ⇒ Object (readonly)
Returns the value of attribute document.
7 8 9 |
# File 'app/services/geoblacklight_admin/image_service.rb', line 7 def document @document end |
#logger=(value) ⇒ Object (writeonly)
Sets the attribute logger
8 9 10 |
# File 'app/services/geoblacklight_admin/image_service.rb', line 8 def logger=(value) @logger = value end |
#metadata=(value) ⇒ Object (writeonly)
Sets the attribute metadata
8 9 10 |
# File 'app/services/geoblacklight_admin/image_service.rb', line 8 def (value) @metadata = value end |
Instance Method Details
#store ⇒ Boolean
Stores the document’s image in ActiveStorage
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'app/services/geoblacklight_admin/image_service.rb', line 30 def store # Gentle hands sleep(1) io_file = image_tempfile(@document.id) if io_file.nil? || @metadata["placeheld"] == true @metadata["IO"] = "NIL" @document.thumbnail_state_machine.transition_to!(:placeheld, @metadata) else attach_io(io_file) end log_output rescue => e @metadata["exception"] = e.inspect @document.thumbnail_state_machine.transition_to!(:failed, @metadata) log_output end |