Created
February 23, 2018 22:00
-
-
Save thermistor/950cf32611cd54cafbd293d1f6621f44 to your computer and use it in GitHub Desktop.
Re-open Interactor and add method to validate context
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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