Class: Courtier::Setup

Inherits:
Object
  • Object
show all
Defined in:
lib/courtier/setup.rb

Overview

Tool configuration setup is used to customize how a tool handles configuration.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(feature, options = {}, &block) ⇒ Setup

Intialize new configuration setup.



11
12
13
14
15
16
17
18
19
20
# File 'lib/courtier/setup.rb', line 11

def initialize(feature, options={}, &block)
  @feature = feature.to_s

  @command = @feature
  @command = options[:command] || options[:tool] if options.key?(:command) || options.key?(:tool)

  @profile = options[:profile] if options.key?(:profile)

  @block = block
end

Instance Attribute Details

#featureObject (readonly)

Feature for which this is the configuration setup.



25
26
27
# File 'lib/courtier/setup.rb', line 25

def feature
  @feature
end

Instance Method Details

#call(config) ⇒ Object



30
31
32
33
34
35
# File 'lib/courtier/setup.rb', line 30

def call(config)
  return unless config.command == @command.to_s if @command
  return unless config.profile == @profile.to_s if @profile

  @block.call(config)
end

#to_procObject



40
41
42
# File 'lib/courtier/setup.rb', line 40

def to_proc
  @block
end