Module: Capistrano::ImmutableTask
- Defined in:
- lib/capistrano/immutable_task.rb
Overview
This module extends a Rake::Task to freeze it to prevent it from being enhanced. This is used to prevent users from enhancing a task at the wrong point of Capistrano’s boot process, which can happen if a Capistrano plugin is loaded in deploy.rb by mistake (instead of in the Capfile).
Usage:
task = Rake.application task.invoke task.extend(Capistrano::ImmutableTask) # prevent further modifications
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.extended(task) ⇒ Object
14 15 16 |
# File 'lib/capistrano/immutable_task.rb', line 14 def self.extended(task) task.freeze end |
Instance Method Details
#enhance(*args, &block) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/capistrano/immutable_task.rb', line 18 def enhance(*args, &block) $stderr.puts <<-MESSAGE ERROR: #{name} has already been invoked and can no longer be modified. Check that you haven't loaded a Capistrano plugin in deploy.rb or a stage (e.g. deploy/production.rb) by mistake. Plugins must be loaded in the Capfile to initialize properly. MESSAGE # This will raise a frozen object error super(*args, &block) end |