Class: Raz::ConfigFile
- Inherits:
-
Object
- Object
- Raz::ConfigFile
- Defined in:
- lib/raz/config_file.rb
Instance Attribute Summary collapse
- #ignored_paths ⇒ Array<String> readonly
- #items ⇒ Array<Raz::Items::Group> readonly
- #path ⇒ String readonly
- #procs ⇒ Hash<Symbol, Array<Proc>> readonly
Instance Method Summary collapse
- #after_backup(&block) ⇒ Object
- #after_restore(&block) ⇒ Object
- #app(name, &block) ⇒ Object
- #before_backup(&block) ⇒ Object
- #before_restore(&block) ⇒ Object
-
#group(name, &block) ⇒ Object
API.
- #ignore_path(path) ⇒ Object
-
#initialize(path = nil, &block) ⇒ ConfigFile
constructor
A new instance of ConfigFile.
Constructor Details
#initialize(path = nil, &block) ⇒ ConfigFile
Returns a new instance of ConfigFile.
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/raz/config_file.rb', line 26 def initialize(path = nil, &block) @path = path @items = [] @ignored_paths = [] @procs = {} if block_given? instance_eval(&block) else instance_eval(File.read(path), path) end end |
Instance Attribute Details
#ignored_paths ⇒ Array<String> (readonly)
18 19 20 |
# File 'lib/raz/config_file.rb', line 18 def ignored_paths @ignored_paths end |
#items ⇒ Array<Raz::Items::Group> (readonly)
14 15 16 |
# File 'lib/raz/config_file.rb', line 14 def items @items end |
#path ⇒ String (readonly)
10 11 12 |
# File 'lib/raz/config_file.rb', line 10 def path @path end |
#procs ⇒ Hash<Symbol, Array<Proc>> (readonly)
22 23 24 |
# File 'lib/raz/config_file.rb', line 22 def procs @procs end |
Instance Method Details
#after_backup(&block) ⇒ Object
59 60 61 62 |
# File 'lib/raz/config_file.rb', line 59 def after_backup(&block) @procs[:after_backup] ||= [] @procs[:after_backup] << block end |
#after_restore(&block) ⇒ Object
69 70 71 72 |
# File 'lib/raz/config_file.rb', line 69 def after_restore(&block) @procs[:after_restore] ||= [] @procs[:after_restore] << block end |
#app(name, &block) ⇒ Object
45 46 47 |
# File 'lib/raz/config_file.rb', line 45 def app(name, &block) @items << Raz::Items::Application.new(name, &block) end |
#before_backup(&block) ⇒ Object
54 55 56 57 |
# File 'lib/raz/config_file.rb', line 54 def before_backup(&block) @procs[:before_backup] ||= [] @procs[:before_backup] << block end |
#before_restore(&block) ⇒ Object
64 65 66 67 |
# File 'lib/raz/config_file.rb', line 64 def before_restore(&block) @procs[:before_restore] ||= [] @procs[:before_restore] << block end |
#group(name, &block) ⇒ Object
API
41 42 43 |
# File 'lib/raz/config_file.rb', line 41 def group(name, &block) @items << Raz::Items::Group.new(name, &block) end |
#ignore_path(path) ⇒ Object
49 50 51 |
# File 'lib/raz/config_file.rb', line 49 def ignore_path(path) @ignored_paths << path end |