Class: FileMover
- Inherits:
-
Object
- Object
- FileMover
- Includes:
- Gitlab::Utils::StrongMemoize
- Defined in:
- app/uploaders/file_mover.rb
Instance Attribute Summary collapse
-
#file_name ⇒ Object
readonly
Returns the value of attribute file_name.
-
#from_model ⇒ Object
readonly
Returns the value of attribute from_model.
-
#secret ⇒ Object
readonly
Returns the value of attribute secret.
-
#to_model ⇒ Object
readonly
Returns the value of attribute to_model.
-
#update_field ⇒ Object
readonly
Returns the value of attribute update_field.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(file_path, update_field = :description, from_model:, to_model:) ⇒ FileMover
constructor
A new instance of FileMover.
Constructor Details
#initialize(file_path, update_field = :description, from_model:, to_model:) ⇒ FileMover
Returns a new instance of FileMover.
8 9 10 11 12 13 14 |
# File 'app/uploaders/file_mover.rb', line 8 def initialize(file_path, update_field = :description, from_model:, to_model:) @secret = File.split(File.dirname(file_path)).last @file_name = File.basename(file_path) @from_model = from_model @to_model = to_model @update_field = update_field end |
Instance Attribute Details
#file_name ⇒ Object (readonly)
Returns the value of attribute file_name.
6 7 8 |
# File 'app/uploaders/file_mover.rb', line 6 def file_name @file_name end |
#from_model ⇒ Object (readonly)
Returns the value of attribute from_model.
6 7 8 |
# File 'app/uploaders/file_mover.rb', line 6 def from_model @from_model end |
#secret ⇒ Object (readonly)
Returns the value of attribute secret.
6 7 8 |
# File 'app/uploaders/file_mover.rb', line 6 def secret @secret end |
#to_model ⇒ Object (readonly)
Returns the value of attribute to_model.
6 7 8 |
# File 'app/uploaders/file_mover.rb', line 6 def to_model @to_model end |
#update_field ⇒ Object (readonly)
Returns the value of attribute update_field.
6 7 8 |
# File 'app/uploaders/file_mover.rb', line 6 def update_field @update_field end |
Instance Method Details
#execute ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/uploaders/file_mover.rb', line 16 def execute temp_file_uploader.retrieve_from_store!(file_name) return unless valid? uploader.retrieve_from_store!(file_name) move if update_markdown update_upload_model end end |