Class: VagrantPlugins::Cachier::Config
- Inherits:
-
Object
- Object
- VagrantPlugins::Cachier::Config
- Defined in:
- lib/vagrant-cachier/config.rb
Constant Summary collapse
- ALLOWED_SCOPES =
%w( box machine )
Instance Attribute Summary collapse
-
#auto_detect ⇒ Object
Returns the value of attribute auto_detect.
-
#buckets ⇒ Object
readonly
Returns the value of attribute buckets.
-
#enable_nfs ⇒ Object
Returns the value of attribute enable_nfs.
-
#scope ⇒ Object
Returns the value of attribute scope.
Instance Method Summary collapse
- #enable(bucket, opts = {}) ⇒ Object
- #enabled? ⇒ Boolean
- #finalize! ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #validate(machine) ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
9 10 11 12 13 |
# File 'lib/vagrant-cachier/config.rb', line 9 def initialize @scope = UNSET_VALUE @auto_detect = UNSET_VALUE @enable_nfs = UNSET_VALUE end |
Instance Attribute Details
#auto_detect ⇒ Object
Returns the value of attribute auto_detect.
4 5 6 |
# File 'lib/vagrant-cachier/config.rb', line 4 def auto_detect @auto_detect end |
#buckets ⇒ Object (readonly)
Returns the value of attribute buckets.
5 6 7 |
# File 'lib/vagrant-cachier/config.rb', line 5 def buckets @buckets end |
#enable_nfs ⇒ Object
Returns the value of attribute enable_nfs.
4 5 6 |
# File 'lib/vagrant-cachier/config.rb', line 4 def enable_nfs @enable_nfs end |
#scope ⇒ Object
Returns the value of attribute scope.
4 5 6 |
# File 'lib/vagrant-cachier/config.rb', line 4 def scope @scope end |
Instance Method Details
#enable(bucket, opts = {}) ⇒ Object
15 16 17 |
# File 'lib/vagrant-cachier/config.rb', line 15 def enable(bucket, opts = {}) (@buckets ||= {})[bucket] = opts end |
#enabled? ⇒ Boolean
40 41 42 43 |
# File 'lib/vagrant-cachier/config.rb', line 40 def enabled? @enabled ||= @auto_detect != UNSET_VALUE || @buckets != nil end |
#finalize! ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/vagrant-cachier/config.rb', line 31 def finalize! return unless enabled? @scope = :box if @scope == UNSET_VALUE @auto_detect = false if @auto_detect == UNSET_VALUE @enable_nfs = false if @enable_nfs == UNSET_VALUE @buckets = @buckets ? @buckets.dup : {} end |
#validate(machine) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/vagrant-cachier/config.rb', line 19 def validate(machine) errors = _detected_errors if enabled? && ! ALLOWED_SCOPES.include?(@scope.to_s) errors << I18n.t('vagrant_cachier.unknown_cache_scope', allowed: ALLOWED_SCOPES.inspect, cache_scope: @scope) end { "vagrant cachier" => errors } end |