Class: CarrierwaveReuploadFix::ReuploadFixer
- Inherits:
-
Object
- Object
- CarrierwaveReuploadFix::ReuploadFixer
- Defined in:
- lib/carrierwave_reupload_fix/reupload_fixer.rb
Instance Attribute Summary collapse
-
#extension_assigner ⇒ Object
readonly
Returns the value of attribute extension_assigner.
-
#model_instance ⇒ Object
readonly
Returns the value of attribute model_instance.
-
#versions_recreator ⇒ Object
readonly
Returns the value of attribute versions_recreator.
Instance Method Summary collapse
- #fix ⇒ Object
- #fix_carrierwave_processing(obj) ⇒ Object
- #handle_associations ⇒ Object
-
#initialize(model_instance, versions_recreator, extension_assigner) ⇒ ReuploadFixer
constructor
A new instance of ReuploadFixer.
Constructor Details
#initialize(model_instance, versions_recreator, extension_assigner) ⇒ ReuploadFixer
Returns a new instance of ReuploadFixer.
5 6 7 8 9 |
# File 'lib/carrierwave_reupload_fix/reupload_fixer.rb', line 5 def initialize(model_instance, versions_recreator, extension_assigner) @model_instance = model_instance @versions_recreator = versions_recreator @extension_assigner = extension_assigner end |
Instance Attribute Details
#extension_assigner ⇒ Object (readonly)
Returns the value of attribute extension_assigner.
4 5 6 |
# File 'lib/carrierwave_reupload_fix/reupload_fixer.rb', line 4 def extension_assigner @extension_assigner end |
#model_instance ⇒ Object (readonly)
Returns the value of attribute model_instance.
4 5 6 |
# File 'lib/carrierwave_reupload_fix/reupload_fixer.rb', line 4 def model_instance @model_instance end |
#versions_recreator ⇒ Object (readonly)
Returns the value of attribute versions_recreator.
4 5 6 |
# File 'lib/carrierwave_reupload_fix/reupload_fixer.rb', line 4 def versions_recreator @versions_recreator end |
Instance Method Details
#fix ⇒ Object
11 12 13 14 |
# File 'lib/carrierwave_reupload_fix/reupload_fixer.rb', line 11 def fix fix_carrierwave_processing(model_instance) handle_associations end |
#fix_carrierwave_processing(obj) ⇒ Object
24 25 26 27 |
# File 'lib/carrierwave_reupload_fix/reupload_fixer.rb', line 24 def fix_carrierwave_processing(obj) fix_carrierwave(obj) assign_extensions(obj) end |
#handle_associations ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/carrierwave_reupload_fix/reupload_fixer.rb', line 16 def handle_associations model_instance.associations_marked_for_fix_in_nested_attributes.each do |assoc| Array(model_instance.send(assoc)).each do |record| fix_carrierwave_processing(record) if record.carrierwave_fields_marked_for_fix_on_reupload.present? end end end |