Class: SparseImage::Config
- Inherits:
-
Object
- Object
- SparseImage::Config
- Defined in:
- lib/vagrant-sparseimage.rb
Constant Summary collapse
- @@images =
Singleton
[]
Class Attribute Summary collapse
-
.images ⇒ Object
Returns the value of attribute images.
Instance Method Summary collapse
- #add_image {|image| ... } ⇒ Object
- #finalize! ⇒ Object
- #to_hash ⇒ Object
- #validate(machine) ⇒ Object
Class Attribute Details
.images ⇒ Object
Returns the value of attribute images.
244 245 246 |
# File 'lib/vagrant-sparseimage.rb', line 244 def images @images end |
Instance Method Details
#add_image {|image| ... } ⇒ Object
247 248 249 250 251 252 253 254 |
# File 'lib/vagrant-sparseimage.rb', line 247 def add_image if not block_given? raise 'add_image must be given a block.' end image = ImageConfig.new yield image @@images.push(image) end |
#finalize! ⇒ Object
256 257 258 259 260 |
# File 'lib/vagrant-sparseimage.rb', line 256 def finalize! @@images.each do |image| image.finalize! end end |
#to_hash ⇒ Object
277 278 279 |
# File 'lib/vagrant-sparseimage.rb', line 277 def to_hash return { :images => @@images } end |
#validate(machine) ⇒ Object
262 263 264 265 266 267 268 269 270 271 272 273 274 275 |
# File 'lib/vagrant-sparseimage.rb', line 262 def validate(machine) errors = {} # Validate each of the image configs in turn @@images.each_with_index do |image, i| image_errors = image.validate() if image_errors.length > 0 image_errors.each do |key, value| errors[key] ||= [] errors[key] += value end end end errors end |