class Omnitest::Psychic::CommandTemplate

Attributes

psychic[R]

Public Class Methods

new(psychic, template) click to toggle source
# File lib/omnitest/psychic/command_template.rb, line 6
def initialize(psychic, template)
  @psychic = psychic
  fail ArgumentError, 'Cannot create a nil command' if template.nil?
  @template = template
end

Public Instance Methods

command(params = {}) click to toggle source
# File lib/omnitest/psychic/command_template.rb, line 12
def command(params = {})
  Tokens.replace_tokens(build_command, params)
end
Also aliased as: to_s
execute(params = {}, *args) click to toggle source
# File lib/omnitest/psychic/command_template.rb, line 16
def execute(params = {}, *args)
  shell_opts = args.shift if args.first.is_a? Hash
  shell_opts ||= {}
  @psychic.execute(command(params), shell_opts, *args)
end
to_s(params = {})
Alias for: command

Private Instance Methods

build_command() click to toggle source
# File lib/omnitest/psychic/command_template.rb, line 26
def build_command
  @command ||= if @template.respond_to?(:call)
                 @template.call
               else
                 @template
               end
end