Class: Foreplay::Engine::Role

Inherits:
Object
  • Object
show all
Defined in:
lib/foreplay/engine/role.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(e, m, i) ⇒ Role

Returns a new instance of Role.



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/foreplay/engine/role.rb', line 3

def initialize(e, m, i)
  @environment  = e
  @mode         = m
  @instructions = i
  @servers      = @instructions['servers']

  preposition = mode == :deploy ? 'to' : 'for'

  return if @servers.length == 1

  puts "#{mode.capitalize}ing #{instructions['name'].yellow} #{preposition} #{@servers.join(', ').yellow} "\
       "for the #{instructions['role'].dup.yellow} role in the #{environment.dup.yellow} environment..."
end

Instance Attribute Details

#environmentObject (readonly)

Returns the value of attribute environment.



2
3
4
# File 'lib/foreplay/engine/role.rb', line 2

def environment
  @environment
end

#instructionsObject (readonly)

Returns the value of attribute instructions.



2
3
4
# File 'lib/foreplay/engine/role.rb', line 2

def instructions
  @instructions
end

#modeObject (readonly)

Returns the value of attribute mode.



2
3
4
# File 'lib/foreplay/engine/role.rb', line 2

def mode
  @mode
end

#serversObject (readonly)

Returns the value of attribute servers.



2
3
4
# File 'lib/foreplay/engine/role.rb', line 2

def servers
  @servers
end

Instance Method Details

#threadsObject



17
18
19
20
21
# File 'lib/foreplay/engine/role.rb', line 17

def threads
  servers.map do |server|
    Thread.new { Foreplay::Engine::Server.new(environment, mode, instructions, server).execute }
  end
end