Class: Vagrant::Boxen::OptionsEvaluator

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-boxen/options_evaluator.rb

Overview

TODO: Write specs ;)

Instance Method Summary collapse

Constructor Details

#initialize(allowed_options, &block) ⇒ OptionsEvaluator

Returns a new instance of OptionsEvaluator.



4
5
6
7
8
# File 'lib/vagrant-boxen/options_evaluator.rb', line 4

def initialize(allowed_options, &block)
  @allowed_options = allowed_options
  @block           = block
  @hash            = {}
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/vagrant-boxen/options_evaluator.rb', line 10

def method_missing(method, *args)
  if @allowed_options.include?(method)
    @hash[method] = args.first
  else
    super
  end
end

Instance Method Details

#to_hashObject



18
19
20
21
# File 'lib/vagrant-boxen/options_evaluator.rb', line 18

def to_hash
  instance_eval(&@block)
  @hash
end