Class: VagrantPlugins::Triggers::Config
- Inherits:
-
Object
- Object
- VagrantPlugins::Triggers::Config
- Defined in:
- lib/vagrant-triggers/config.rb
Instance Attribute Summary collapse
-
#triggers ⇒ Object
readonly
Returns the value of attribute triggers.
Instance Method Summary collapse
- #after(actions, options = {}, &block) ⇒ Object
- #before(actions, options = {}, &block) ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #instead_of(actions, options = {}, &block) ⇒ Object (also: #reject)
- #merge(other) ⇒ Object
- #validate(machine) ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
6 7 8 |
# File 'lib/vagrant-triggers/config.rb', line 6 def initialize @triggers = [] end |
Instance Attribute Details
#triggers ⇒ Object (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, = {}, &block) add_trigger(actions, :after, , block) end |
#before(actions, options = {}, &block) ⇒ Object
14 15 16 |
# File 'lib/vagrant-triggers/config.rb', line 14 def before(actions, = {}, &block) add_trigger(actions, :before, , 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, = {}, &block) add_trigger(actions, :instead_of, , 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 |