Class: ActionTracker::Recorder
- Inherits:
-
Object
- Object
- ActionTracker::Recorder
- Defined in:
- lib/action_tracker/recorder.rb
Overview
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)
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #call(target) ⇒ Object
-
#initialize(template_name, template_options = {}) ⇒ Recorder
constructor
A new instance of Recorder.
Constructor Details
#initialize(template_name, template_options = {}) ⇒ Recorder
Returns a new instance of Recorder.
17 18 19 20 |
# File 'lib/action_tracker/recorder.rb', line 17 def initialize(template_name, = {}) @template_name = template_name @options = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
15 16 17 |
# File 'lib/action_tracker/recorder.rb', line 15 def @options end |
Instance Method Details
#call(target) ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/action_tracker/recorder.rb', line 22 def call(target) form = [: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 |