Class: VagrantPlugins::DataBags::Config
- Inherits:
-
Object
- Object
- VagrantPlugins::DataBags::Config
- Defined in:
- lib/vagrant-databags/config.rb
Constant Summary collapse
- MAYBE =
Object.new.freeze
Instance Attribute Summary collapse
-
#cleanup_on_provision ⇒ Boolean
Data bags map configuration.
-
#map ⇒ Hash
Data bags map configuration.
Instance Method Summary collapse
- #finalize! ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #missing?(obj) ⇒ Boolean
- #to_hash ⇒ Object
- #validate(machine) ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
16 17 18 19 20 21 22 23 |
# File 'lib/vagrant-databags/config.rb', line 16 def initialize super @map = Hash.new @cleanup_on_provision = false @__finalized = false end |
Instance Attribute Details
#cleanup_on_provision ⇒ Boolean
Data bags map configuration.
14 15 16 |
# File 'lib/vagrant-databags/config.rb', line 14 def cleanup_on_provision @cleanup_on_provision end |
#map ⇒ Hash
Data bags map configuration.
10 11 12 |
# File 'lib/vagrant-databags/config.rb', line 10 def map @map end |
Instance Method Details
#finalize! ⇒ Object
25 26 27 |
# File 'lib/vagrant-databags/config.rb', line 25 def finalize! @__finalized = true end |
#missing?(obj) ⇒ Boolean
60 61 62 |
# File 'lib/vagrant-databags/config.rb', line 60 def missing?(obj) obj.to_s.strip.empty? end |
#to_hash ⇒ Object
51 52 53 54 55 56 57 58 |
# File 'lib/vagrant-databags/config.rb', line 51 def to_hash raise "Must finalize first." if !@__finalized { cleanup_on_provision: @cleanup_on_provision, map: @map } end |
#validate(machine) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/vagrant-databags/config.rb', line 29 def validate(machine) errors = _detected_errors if @map.is_a?(Hash) @map.each do |k, v| if v.respond_to? :call unless v.arity == 2 errors << "#{k} data bag map configuration is expected to be lambda with 2 arguments!" end else errors << "#{k} data bag map configuration is expected to be lambda!" end end else errors << "Data bag map configuration is expected to be a hash!" end { "DataBags" => errors } end |