Class: Dgrid::API::Workspace::Backup_0_2

Inherits:
Backup_0_1 show all
Defined in:
lib/dgrid/api/workspace.rb

Overview

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Backup

#backed_up_classes, create, current_valid_backup_class, #current_valid_backup_class, #entity_classes, #initialize, migrate, #restore_into

Methods included from SetMembersFromHash

#change_string_keys_to_symbol_keys, #set_members_from_hash, #split_hash

Constructor Details

This class inherits a constructor from Dgrid::API::Workspace::Backup

Class Method Details

.backed_up_classesObject



464
465
466
# File 'lib/dgrid/api/workspace.rb', line 464

def self.backed_up_classes
  self.entity_classes
end

.entity_classesObject



458
459
460
461
462
# File 'lib/dgrid/api/workspace.rb', line 458

def self.entity_classes 
  # This is the only real difference between versions 0_1 and 0_2
  # Incident promoted to base-level entity and Keywords added.
  @@entity_classes ||= predecessor.entity_classes + [Incident, Keyword]
end

Instance Method Details

#migrate_from_predecessor(predecessor) ⇒ Object



468
469
470
471
472
473
474
475
476
477
478
479
# File 'lib/dgrid/api/workspace.rb', line 468

def migrate_from_predecessor(predecessor)
  pred_entity_classes = Set.new(predecessor.class.entity_classes)
  self.class.entity_classes.each do |entity_class|
    if pred_entity_classes.include?(entity_class)
      pred_entities = predecessor.get_entities_hash(entity_class)
      set_entities_hash(my_entity_class,pred_entities.clone)
    end
  end
  if self.incidents_are_entities? && !pred_entity_classes.include?(Incident)
    migrate_item_subord_incidents_to_entity_incidents(predecessor)
  end
end