Class: MysqlBackup::Librarian::BackupCollection

Inherits:
Object
  • Object
show all
Includes:
NamedArguments
Defined in:
lib/mysql_backup/librarian/backup_collection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#groupsObject

Returns the value of attribute groups.



15
16
17
# File 'lib/mysql_backup/librarian/backup_collection.rb', line 15

def groups
  @groups
end

Instance Method Details

#add_backup_group(g) ⇒ Object



18
19
20
# File 'lib/mysql_backup/librarian/backup_collection.rb', line 18

def add_backup_group g
  groups << g
end

#add_identifier(identifier) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/mysql_backup/librarian/backup_collection.rb', line 22

def add_identifier identifier
  result = nil
  result = groups.find do |g|
    g.add_identifier_to_group_if_the_identifier_should_be_in_this_group identifier
  end
  unless result
    result = MysqlBackup::Librarian::Backup.create_object :identifier => identifier
    groups << result
  end
  result
end

#each_group(matching_type = Object) ⇒ Object



44
45
46
47
48
49
50
51
# File 'lib/mysql_backup/librarian/backup_collection.rb', line 44

def each_group matching_type = Object
  result = []
  groups.select {|g| matching_type === g}.each do |gg|
    yield gg if block_given?
    result << gg
  end
  result
end

#each_logObject



38
39
40
41
42
# File 'lib/mysql_backup/librarian/backup_collection.rb', line 38

def each_log
  each_group MysqlBackup::Librarian::Backup::Log do |g|
    yield g
  end
end

#find_group(group_name) ⇒ Object



53
54
55
56
57
58
# File 'lib/mysql_backup/librarian/backup_collection.rb', line 53

def find_group group_name
  each_group do |g|
    return g if group_name == g.to_s
  end
  nil
end

#groups_matching_type(t) ⇒ Object



34
35
36
# File 'lib/mysql_backup/librarian/backup_collection.rb', line 34

def groups_matching_type t
  each_group t    
end

#typesObject



60
61
62
# File 'lib/mysql_backup/librarian/backup_collection.rb', line 60

def types
  groups.map(&:class).uniq
end