Class: ATP::Program

Inherits:
Object
  • Object
show all
Defined in:
lib/atp/program.rb

Overview

Program is the top-level container for a collection of test flows

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object

:nodoc:



32
33
34
35
36
37
38
39
40
41
# File 'lib/atp/program.rb', line 32

def method_missing(method, *args, &block) # :nodoc:
  if f = flows[method]
    define_singleton_method method do
      f
    end
    f
  else
    super
  end
end

Class Method Details

.load(file) ⇒ Object

Load a program from a previously saved file



5
6
7
8
9
10
11
# File 'lib/atp/program.rb', line 5

def self.load(file)
  p = nil
  File.open(file) do |f|
    p = Marshal.load(f)
  end
  p
end

Instance Method Details

#flow(name, options = {}) ⇒ Object



13
14
15
# File 'lib/atp/program.rb', line 13

def flow(name, options = {})
  flows[name] ||= Flow.new(self, name, options)
end

#flowsObject



17
18
19
# File 'lib/atp/program.rb', line 17

def flows
  @flows ||= {}
end

#respond_to?(*args) ⇒ Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/atp/program.rb', line 28

def respond_to?(*args)
  flows.key?(args.first) || super
end

#save(file) ⇒ Object

Save the program to a file



22
23
24
25
26
# File 'lib/atp/program.rb', line 22

def save(file)
  File.open(file, 'w') do |f|
    Marshal.dump(self, f)
  end
end