Class: Hyrax::DerivativeBucketedStorage
- Inherits:
-
Object
- Object
- Hyrax::DerivativeBucketedStorage
- Defined in:
- app/services/hyrax/derivative_bucketed_storage.rb
Instance Attribute Summary collapse
-
#base_path ⇒ Object
readonly
Returns the value of attribute base_path.
Instance Method Summary collapse
-
#bucketed_path(id) ⇒ Object
rubocop:enable Lint/UnusedMethodArgument.
-
#generate(resource:, file:, original_filename:) ⇒ Object
rubocop:disable Lint/UnusedMethodArgument.
-
#initialize(base_path:) ⇒ DerivativeBucketedStorage
constructor
A new instance of DerivativeBucketedStorage.
Constructor Details
#initialize(base_path:) ⇒ DerivativeBucketedStorage
Returns a new instance of DerivativeBucketedStorage.
8 9 10 |
# File 'app/services/hyrax/derivative_bucketed_storage.rb', line 8 def initialize(base_path:) @base_path = base_path end |
Instance Attribute Details
#base_path ⇒ Object (readonly)
Returns the value of attribute base_path.
6 7 8 |
# File 'app/services/hyrax/derivative_bucketed_storage.rb', line 6 def base_path @base_path end |
Instance Method Details
#bucketed_path(id) ⇒ Object
rubocop:enable Lint/UnusedMethodArgument
19 20 21 22 23 |
# File 'app/services/hyrax/derivative_bucketed_storage.rb', line 19 def bucketed_path(id) # We want to use the same code the derivative process uses so that items end up # stored in the place we expect them. Hyrax::DerivativePath.new(id.to_s).pair_directory end |
#generate(resource:, file:, original_filename:) ⇒ Object
rubocop:disable Lint/UnusedMethodArgument
13 14 15 16 |
# File 'app/services/hyrax/derivative_bucketed_storage.rb', line 13 def generate(resource:, file:, original_filename:) raise ArgumentError, "original_filename must be provided" unless original_filename Pathname.new(base_path).join(*bucketed_path(resource.id)).join(original_filename) end |