Class: Backup::Syncer::Base
- Inherits:
-
Object
- Object
- Backup::Syncer::Base
- Includes:
- Config::Helpers, Utilities::Helpers
- Defined in:
- lib/backup/syncer/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#excludes ⇒ Object
readonly
Returns the value of attribute excludes.
-
#mirror ⇒ Object
Flag for mirroring the files/directories.
-
#path ⇒ Object
Path to store the synced files/directories to.
-
#syncer_id ⇒ Object
readonly
Optional user-defined identifier to differentiate multiple syncers defined within a single backup model.
Instance Method Summary collapse
- #add(path) ⇒ Object
-
#directories(&block) ⇒ Object
Syntactical suger for the DSL for adding directories.
-
#exclude(pattern) ⇒ Object
For Cloud Syncers,
pattern
can be a string (with shell-style wildcards) or a regex. -
#initialize(syncer_id = nil) ⇒ Base
constructor
A new instance of Base.
Methods included from Config::Helpers
Methods included from Utilities::Helpers
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
#excludes ⇒ Object (readonly)
Returns the value of attribute excludes.
23 24 25 |
# File 'lib/backup/syncer/base.rb', line 23 def excludes @excludes end |
#mirror ⇒ Object
Flag for mirroring the files/directories
15 16 17 |
# File 'lib/backup/syncer/base.rb', line 15 def mirror @mirror end |
#path ⇒ Object
Path to store the synced files/directories to
11 12 13 |
# File 'lib/backup/syncer/base.rb', line 11 def path @path end |
#syncer_id ⇒ Object (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 |