Module: Labimotion::GenericRevisions
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/labimotion/models/concerns/generic_revisions.rb
Instance Method Summary collapse
Instance Method Details
#create_vault ⇒ Object
13 14 15 |
# File 'lib/labimotion/models/concerns/generic_revisions.rb', line 13 def create_vault save_to_vault unless self.class.name == 'Labimotion::Element' end |
#delete_attachments ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/labimotion/models/concerns/generic_revisions.rb', line 29 def att_ids = [] properties && properties[Labimotion::Prop::LAYERS]&.keys&.each do |key| layer = properties[Labimotion::Prop::LAYERS][key] field_uploads = layer[Labimotion::Prop::FIELDS].select { |ss| ss['type'] == Labimotion::FieldType::UPLOAD } field_uploads.each do |field| (field['value'] && field['value']['files'] || []).each do |file| att_ids.push(file['aid']) unless file['aid'].nil? end end end Attachment.where(id: att_ids, attachable_id: id, attachable_type: %w[ElementProps SegmentProps]).destroy_all end |
#save_to_vault ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/labimotion/models/concerns/generic_revisions.rb', line 17 def save_to_vault attributes = { uuid: uuid, klass_uuid: klass_uuid, properties: properties, properties_release: properties_release } attributes["#{Labimotion::Utils.element_name_dc(self.class.name)}_id"] = id attributes['name'] = name if self.class.name == 'Labimotion::Element' "#{self.class.name}sRevision".constantize.create(attributes) end |