Sha256: 0dd9e67f590911866002b1c111472fc3c2d8a0c81859bf5af396a12fec07d6da

Contents?: true

Size: 804 Bytes

Versions: 4

Compression:

Stored size: 804 Bytes

Contents

module ATP
  # Program is the top-level container for a collection of test flows
  class Program
    # Load a program from a previously saved file
    def self.load(file)
      p = nil
      File.open(file) do |f|
        p = Marshal.load(f)
      end
      p
    end

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

    def flows
      @flows ||= {}
    end

    # Save the program to a file
    def save(file)
      File.open(file, 'w') do |f|
        Marshal.dump(self, f)
      end
    end

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

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
atp-0.3.3 lib/atp/program.rb
atp-0.3.2 lib/atp/program.rb
atp-0.3.1 lib/atp/program.rb
atp-0.3.0 lib/atp/program.rb