Class: ConfigmonkeyCli::Application::ManifestAction::Custom

Inherits:
Base
  • Object
show all
Defined in:
lib/configmonkey_cli/application/manifest_actions/custom.rb

Defined Under Namespace

Classes: Proxy

Instance Attribute Summary

Attributes inherited from Base

#app, #args, #manifest, #opts, #thor

Instance Method Summary collapse

Methods inherited from Base

#args_and_opts, #exists?, #expand_dst, #expand_src, #initialize, #rel, #to_s

Constructor Details

This class inherits a constructor from ConfigmonkeyCli::Application::ManifestAction::Base

Instance Method Details

#destructiveObject



24
25
26
27
28
# File 'lib/configmonkey_cli/application/manifest_actions/custom.rb', line 24

def destructive
  @args.each do |scope, block|
    block.call(self, manifest) if scope == :always || scope == :destructive
  end
end

#init(label = nil, &block) ⇒ Object



5
6
7
8
# File 'lib/configmonkey_cli/application/manifest_actions/custom.rb', line 5

def init label = nil, &block
  @label = label
  block.call(Proxy.new(self)) if block
end

#inspectObject



10
11
12
# File 'lib/configmonkey_cli/application/manifest_actions/custom.rb', line 10

def inspect
  @label ? super.gsub("Custom @args", "Custom @label=#{@label} @args") : super
end

#prepareObject



14
15
16
# File 'lib/configmonkey_cli/application/manifest_actions/custom.rb', line 14

def prepare
  status :proc, :yellow, (@label || "unlabeled custom block"), :blue
end

#simulateObject



18
19
20
21
22
# File 'lib/configmonkey_cli/application/manifest_actions/custom.rb', line 18

def simulate
  @args.each do |scope, block|
    block.call(self, manifest) if scope == :always || scope == :simulate
  end
end