Skip to content

Instantly share code, notes, and snippets.

@thermistor
Created February 23, 2018 22:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thermistor/950cf32611cd54cafbd293d1f6621f44 to your computer and use it in GitHub Desktop.
Save thermistor/950cf32611cd54cafbd293d1f6621f44 to your computer and use it in GitHub Desktop.
Re-open Interactor and add method to validate context
module Interactor
def require_in_context(*names)
context_keys = context.keys
names.each do |name|
if !context_keys.include?(name)
raise "Interactor #{self.class.name} requires #{name.inspect} but it wasn't found in context."
end
end
names.map do |name|
self.send(name)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment