Class: Backup::Config::DSL
- Inherits:
-
Object
- Object
- Backup::Config::DSL
- Defined in:
- lib/backup/config/dsl.rb
Overview
Context for loading user config.rb and model files.
Defined Under Namespace
Classes: Error
Constant Summary collapse
- Model =
Backup::Model
Instance Attribute Summary collapse
-
#_config_options ⇒ Object
readonly
Returns the value of attribute _config_options.
Instance Method Summary collapse
-
#initialize ⇒ DSL
constructor
A new instance of DSL.
-
#preconfigure(name, &block) ⇒ Object
Allows users to create preconfigured models.
Constructor Details
#initialize ⇒ DSL
Returns a new instance of DSL.
79 80 81 |
# File 'lib/backup/config/dsl.rb', line 79 def initialize = {} end |
Instance Attribute Details
#_config_options ⇒ Object (readonly)
Returns the value of attribute _config_options.
77 78 79 |
# File 'lib/backup/config/dsl.rb', line 77 def end |
Instance Method Details
#preconfigure(name, &block) ⇒ Object
Allows users to create preconfigured models.
89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/backup/config/dsl.rb', line 89 def preconfigure(name, &block) unless name.is_a?(String) && name =~ /^[A-Z]/ raise Error, "Preconfigured model names must be given as a string " + "and start with a capital letter." end if DSL.const_defined?(name) raise Error, "'#{ name }' is already in use " + "and can not be used for a preconfigured model." end DSL.const_set(name, Class.new(Model)) DSL.const_get(name).preconfigure(&block) end |