class ActionTracker::Recorder
Usage:
ActionTracker::Recorder.new(:create).call(order) usage with wisper gem: (https://github.com/krisleech/wisper) MyPublisher.suscribe(ActionTracker::Recorder.new(:update), on: :ok, with: :call)
Attributes
options[R]
Public Class Methods
new(template_name, template_options = {})
click to toggle source
# File lib/action_tracker/recorder.rb, line 17 def initialize(template_name, template_options = {}) @template_name = template_name @options = template_options end
Public Instance Methods
call(target)
click to toggle source
# File lib/action_tracker/recorder.rb, line 22 def call(target) form = options[:form] || build_form(target) return form.errors unless form.valid? raise EmptyTargetError, inspect unless target @response = ActionTracker::Workers::Factory.new(form).instance.perform @response.to_h end
Private Instance Methods
build_form(target)
click to toggle source
# File lib/action_tracker/recorder.rb, line 33 def build_form(target) template_klass.new(target, options).form end
template_klass()
click to toggle source
# File lib/action_tracker/recorder.rb, line 41 def template_klass klass = "ActionTracker::Templates::#{template_name}".safe_constantize raise UndefinedTemplateError, template_name unless klass klass end
template_name()
click to toggle source
# File lib/action_tracker/recorder.rb, line 37 def template_name @template_name.to_s.classify end