class Hesburgh::Lib::Runner

A Runner is responsible for performing the guts of what might traditionally be a controller's action.

It exists for two reasons, though this is not considered exhaustive:

So, the Runner provides a seem in the code in which you can more readily make changes to the “inner method” of a route. In some ways, I see this as a separation of state change and response; a somewhat analogous separation to the Command/Query separation principle.

@see Hesrbugh::Lib::MockRunner

Attributes

context[R]

Public Class Methods

new(context, callbacks: nil) { |callbacks| ... } click to toggle source
# File lib/hesburgh/lib/runner.rb, line 27
def initialize(context, callbacks: nil)
  @callbacks = callbacks || default_callbacks
  @context = context
  yield(@callbacks) if block_given?
end
run(context, *args, &block) click to toggle source
# File lib/hesburgh/lib/runner.rb, line 20
def self.run(context, *args, &block)
  new(context, &block).run(*args)
end

Public Instance Methods

callback(name, *args) click to toggle source
# File lib/hesburgh/lib/runner.rb, line 33
def callback(name, *args)
  @callbacks.call(name, *args)
  return name, *args
end
run(*_args) click to toggle source
# File lib/hesburgh/lib/runner.rb, line 38
def run(*_args)
  raise(NotImplementedError, "You must define #{self.class}#run")
end

Private Instance Methods

default_callbacks() click to toggle source
# File lib/hesburgh/lib/runner.rb, line 44
def default_callbacks
  require 'hesburgh/lib/named_callbacks'
  NamedCallbacks.new
end