Class: Viaduct::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/viaduct/runner.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.run(app, options = nil) ⇒ Object



3
4
5
# File 'lib/viaduct/runner.rb', line 3

def self.run(app, options=nil)
  new.run(app, options)
end

Instance Method Details

#run(callable_id, options = nil) ⇒ Object

Raises:

  • (ArgumentError)


7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/viaduct/runner.rb', line 7

def run(callable_id, options=nil)
  callable = callable_id
  callable = Builder.new.use(callable_id) if callable_id.kind_of?(Class)
  raise ArgumentError, "Argument to run must be a callable object or known class." if !callable || !callable.respond_to?(:call)

  # Create the initial environment with the options given
  environment = Environment.new
  environment.merge!(options || {})

  callable.call(environment)
  environment
end