Class: VagrantPlugins::Triggers::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-triggers/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



6
7
8
# File 'lib/vagrant-triggers/config.rb', line 6

def initialize
  @triggers = []
end

Instance Attribute Details

#triggersObject (readonly)

Returns the value of attribute triggers.



4
5
6
# File 'lib/vagrant-triggers/config.rb', line 4

def triggers
  @triggers
end

Instance Method Details

#after(actions, options = {}, &block) ⇒ Object



10
11
12
# File 'lib/vagrant-triggers/config.rb', line 10

def after(actions, options = {}, &block)
  add_trigger(actions, :after, options, block)
end

#before(actions, options = {}, &block) ⇒ Object



14
15
16
# File 'lib/vagrant-triggers/config.rb', line 14

def before(actions, options = {}, &block)
  add_trigger(actions, :before, options, block)
end

#instead_of(actions, options = {}, &block) ⇒ Object Also known as: reject



18
19
20
# File 'lib/vagrant-triggers/config.rb', line 18

def instead_of(actions, options = {}, &block)
  add_trigger(actions, :instead_of, options, block)
end

#merge(other) ⇒ Object



23
24
25
26
27
# File 'lib/vagrant-triggers/config.rb', line 23

def merge(other)
  super.tap do |result|
    result.instance_variable_set(:@triggers, @triggers + other.triggers)
  end
end

#validate(machine) ⇒ Object



29
30
31
32
33
34
35
36
37
# File 'lib/vagrant-triggers/config.rb', line 29

def validate(machine)
  errors = []

  if @__invalid_methods && !@__invalid_methods.empty?
    errors << I18n.t("vagrant.config.common.bad_field", :fields => @__invalid_methods.to_a.sort.join(", "))
  end

  { "triggers" => errors }
end