Class: Balmora::Command::Links

Inherits:
Balmora::Command show all
Defined in:
lib/balmora/command/links.rb

Defined Under Namespace

Classes: Error

Instance Method Summary collapse

Methods inherited from Balmora::Command

#_execute, #execute, #initialize, #option

Constructor Details

This class inherits a constructor from Balmora::Command

Instance Method Details

#_get_command(link) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
# File 'lib/balmora/command/links.rb', line 33

def _get_command(link)
  command = (@options || {}).merge(command: 'link', link: link)

  if link.instance_of?(::Hash)
    command.merge!(link)
  end

  command.merge!(storage: @storage)

  return command
end

#initObject



5
6
7
8
9
10
# File 'lib/balmora/command/links.rb', line 5

def init()
  super()

  @links = @variables.inject(@links)
  @storage = @variables.inject(@storage)
end

#optionsObject



12
13
14
# File 'lib/balmora/command/links.rb', line 12

def options()
  return super().concat([:links, :storage])
end

#runObject



26
27
28
29
30
31
# File 'lib/balmora/command/links.rb', line 26

def run()
  @links.each() { |link|
    command = _get_command(link)
    @balmora.run_command(@state, command)
  }
end

#verifyObject



16
17
18
19
20
21
22
23
24
# File 'lib/balmora/command/links.rb', line 16

def verify()
  if @links.nil?()
    raise Error.new('"links" should be defined')
  end

  if @storage.nil?()
    raise Error.new('"storage" should be defined')
  end
end