Class: Backup::Syncer::Base

Inherits:
Object
  • Object
show all
Includes:
Config::Helpers, Utilities::Helpers
Defined in:
lib/backup/syncer/base.rb

Direct Known Subclasses

Cloud::Base, Cloud::S3, RSync::Base

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Config::Helpers

included

Constructor Details

#initialize(syncer_id = nil) ⇒ Base

Returns a new instance of Base.



25
26
27
28
29
30
31
32
33
# File 'lib/backup/syncer/base.rb', line 25

def initialize(syncer_id = nil)
  @syncer_id = syncer_id

  load_defaults!

  @mirror ||= false
  @directories ||= []
  @excludes ||= []
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Backup::Config::Helpers

Instance Attribute Details

#excludesObject (readonly)

Returns the value of attribute excludes.



23
24
25
# File 'lib/backup/syncer/base.rb', line 23

def excludes
  @excludes
end

#mirrorObject

Flag for mirroring the files/directories



15
16
17
# File 'lib/backup/syncer/base.rb', line 15

def mirror
  @mirror
end

#pathObject

Path to store the synced files/directories to



11
12
13
# File 'lib/backup/syncer/base.rb', line 11

def path
  @path
end

#syncer_idObject (readonly)

Optional user-defined identifier to differentiate multiple syncers defined within a single backup model. Currently this is only used in the log messages.



21
22
23
# File 'lib/backup/syncer/base.rb', line 21

def syncer_id
  @syncer_id
end

Instance Method Details

#add(path) ⇒ Object



42
43
44
# File 'lib/backup/syncer/base.rb', line 42

def add(path)
  directories << path
end

#directories(&block) ⇒ Object

Syntactical suger for the DSL for adding directories



37
38
39
40
# File 'lib/backup/syncer/base.rb', line 37

def directories(&block)
  return @directories unless block_given?
  instance_eval(&block)
end

#exclude(pattern) ⇒ Object

For Cloud Syncers, pattern can be a string (with shell-style wildcards) or a regex. For RSync, each pattern will be passed to rsync’s –exclude option.



49
50
51
# File 'lib/backup/syncer/base.rb', line 49

def exclude(pattern)
  excludes << pattern
end