Class: TestLink::Command::Base
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Definition
argument, arguments, command_name
Class Method Details
.adapt_with(klass) ⇒ Object
Instance Method Details
#arguments_hash ⇒ Object
31
32
33
34
35
36
37
|
# File 'lib/test_link/command/base.rb', line 31
def arguments_hash
args = {}
(Base.arguments.keys + self.class.arguments.keys).each do |name|
args[name] = self.send(name)
end
args
end
|
#check_arguments ⇒ Object
46
47
48
49
50
51
52
|
# File 'lib/test_link/command/base.rb', line 46
def check_arguments
errors = []
self.class.arguments.select{ |name, argument| argument.mandatory? }.keys.each do |name|
errors.push name if arguments_hash[name].nil?
end
errors
end
|
#execute(link) ⇒ Object
24
25
26
27
28
29
|
# File 'lib/test_link/command/base.rb', line 24
def execute link
self.devKey ||= link.key
errors = check_arguments
raise ArgumentError.new "Missing mandatory argument(s) #{errors}" unless errors.empty?
link.client.call 'tl.' + self.class.command_name, arguments_hash.reject { |key, value| value.nil? }
end
|
#reset_arguments_hash(hash) ⇒ Object
39
40
41
42
43
44
|
# File 'lib/test_link/command/base.rb', line 39
def reset_arguments_hash hash
arguments_hash.keys.each do |name|
assignment = (name.to_s + '=').to_sym
send(assignment, hash[name])
end
end
|