class Interactors::Simple
Anonymous
interactors Does two things:
- passes context to the proc - honors #compose interface - Only return [:error, ... ] if exception is raised - otherwise, always return [:ok, context]
Attributes
block[R]
Public Class Methods
new(&blk)
click to toggle source
# File lib/interactors/simple.rb, line 14 def initialize(&blk) @block = blk end
Public Instance Methods
call(context = {})
click to toggle source
# File lib/interactors/simple.rb, line 18 def call(context = {}) handle_error do block.call(context) end end
handle_error() { || ... }
click to toggle source
This is meant to be overridable. Maybe you want to use something else, such as capturing network errors, or wrap around specific third-party libraries.
# File lib/interactors/simple.rb, line 28 def handle_error yield [:ok, context] rescue Exception => e [:error, e] end