Class: VagrantPlugins::VirtualHostsUpdater::Action::BaseAction
- Inherits:
-
Object
- Object
- VagrantPlugins::VirtualHostsUpdater::Action::BaseAction
- Includes:
- VirtualHostsUpdater
- Defined in:
- lib/vagrant-virtual-hostsupdater/Action/BaseAction.rb
Direct Known Subclasses
Constant Summary collapse
- @@completed =
Vagrant 2.2.14 has changed the hooks execution policy so they started to be triggered more than once (a lot actually) which is non-performant and floody. With this static property, we control the executions and allowing just one.
{}
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, env) ⇒ BaseAction
constructor
A new instance of BaseAction.
- #run(env) ⇒ Object
Methods included from VirtualHostsUpdater
#addHostEntries, #addToHosts, #adviseOnSudo, #cacheHostEntries, #createHostEntry, #getHostnames, #hostEntryPattern, #host_entry, #removeFromHosts, #removeHostEntries, #signature, #sudo
Constructor Details
#initialize(app, env) ⇒ BaseAction
Returns a new instance of BaseAction.
17 18 19 20 21 |
# File 'lib/vagrant-virtual-hostsupdater/Action/BaseAction.rb', line 17 def initialize(app, env) @app = app @machine = env[:machine] @ui = env[:ui] end |
Instance Method Details
#call(env) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/vagrant-virtual-hostsupdater/Action/BaseAction.rb', line 23 def call(env) # Check whether the plugin has been executed for a particular # VM as it may happen that a single Vagrantfile defines multiple # machines and having a static flag will result in a plugin being # executed just once. # https://github.com/agiledivider/vagrant-hostsupdater/issues/198 if @machine.id and not @@completed.key?("#{self.class.name}-#{@machine.name}") run(env) @@completed["#{self.class.name}-#{@machine.name}"] = true end @app.call(env) end |
#run(env) ⇒ Object
37 38 39 |
# File 'lib/vagrant-virtual-hostsupdater/Action/BaseAction.rb', line 37 def run(env) raise NotImplementedError.new("Must be implemented!") end |