Class: Dgrid::API::Workspace::Backup
- Inherits:
-
Object
- Object
- Dgrid::API::Workspace::Backup
show all
- Includes:
- SetMembersFromHash
- Defined in:
- lib/dgrid/api/workspace.rb
Class Method Summary
collapse
Instance Method Summary
collapse
#change_string_keys_to_symbol_keys, #set_members_from_hash, #split_hash
Constructor Details
#initialize(workspace = nil) ⇒ Backup
Returns a new instance of Backup.
192
193
194
195
|
# File 'lib/dgrid/api/workspace.rb', line 192
def initialize(workspace = nil)
raise "Backup is a pure virtual class. Use Backup.create instead of Backup.new" unless self.class != Backup
hashify_all_members(workspace) unless workspace.nil?
end
|
Class Method Details
.backed_up_classes ⇒ Object
218
219
220
|
# File 'lib/dgrid/api/workspace.rb', line 218
def self.backed_up_classes
self.entity_classes
end
|
.create(workspace) ⇒ Object
206
207
208
|
# File 'lib/dgrid/api/workspace.rb', line 206
def self.create(workspace)
self.current_valid_backup_class.new(workspace)
end
|
.current_valid_backup_class ⇒ Object
197
198
199
200
|
# File 'lib/dgrid/api/workspace.rb', line 197
def self.current_valid_backup_class
Backup_0_2
end
|
.entity_classes ⇒ Object
210
211
212
|
# File 'lib/dgrid/api/workspace.rb', line 210
def self.entity_classes
raise "Pure Virtual self.entity_classes needs to be overridden in #{self.class.name}"
end
|
.migrate(backup_of_wrong_class) ⇒ Object
235
236
237
238
239
240
241
|
# File 'lib/dgrid/api/workspace.rb', line 235
def self.migrate(backup_of_wrong_class)
raise "Cannot migrate anything to class #{self.name}" unless self.predecessor
backup_of_predecessor_class = (backup_of_wrong_class.class == self.predecessor) ? backup_of_wrong_class : self.predecessor.migrate(backup_of_wrong_class)
migrated = self.new
migrated.migrate_from_predecessor(backup_of_predecessor_class)
migrated
end
|
Instance Method Details
#backed_up_classes ⇒ Object
222
223
224
|
# File 'lib/dgrid/api/workspace.rb', line 222
def backed_up_classes
self.class.backed_up_classes
end
|
#current_valid_backup_class ⇒ Object
202
203
204
|
# File 'lib/dgrid/api/workspace.rb', line 202
def current_valid_backup_class
self.class.current_valid_backup_class
end
|
#entity_classes ⇒ Object
214
215
216
|
# File 'lib/dgrid/api/workspace.rb', line 214
def entity_classes
self.class.entity_classes
end
|
#migrate_from_predecessor(predecessor) ⇒ Object
243
244
245
|
# File 'lib/dgrid/api/workspace.rb', line 243
def migrate_from_predecessor(predecessor)
raise "Pure Virtual migrate_from_predecessor needs to be overridden in #{self.class.name}"
end
|
#restore_into(workspace) ⇒ Object
226
227
228
229
230
231
232
233
|
# File 'lib/dgrid/api/workspace.rb', line 226
def restore_into(workspace)
if self.class == current_valid_backup_class
do_restore(workspace)
else
restorable_backup = current_valid_backup_class.migrate(self)
restorable_backup.restore_into(workspace)
end
end
|