Class: Evento::Orchestrator
- Inherits:
-
Object
- Object
- Evento::Orchestrator
- Defined in:
- lib/evento/orchestrator.rb
Instance Attribute Summary collapse
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
Instance Method Summary collapse
- #after_audit_trail_commit(name, &block) ⇒ Object
- #after_transaction_log_commit(name, &block) ⇒ Object
- #define_event_methods_on(target_klass, options = {}, &block) ⇒ Object
-
#initialize(klass, options = {}) ⇒ Orchestrator
constructor
A new instance of Orchestrator.
- #override_devise_notification(&block) ⇒ Object
Constructor Details
#initialize(klass, options = {}) ⇒ Orchestrator
Returns a new instance of Orchestrator.
7 8 9 10 11 |
# File 'lib/evento/orchestrator.rb', line 7 def initialize(klass, = {}) @klass = klass @options = @extractor = nil end |
Instance Attribute Details
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
5 6 7 |
# File 'lib/evento/orchestrator.rb', line 5 def klass @klass end |
Instance Method Details
#after_audit_trail_commit(name, &block) ⇒ Object
18 19 20 21 |
# File 'lib/evento/orchestrator.rb', line 18 def after_audit_trail_commit(name, &block) association = extractor.extract_audit_trail_association() after_association_commit(association, name, &block) end |
#after_transaction_log_commit(name, &block) ⇒ Object
13 14 15 16 |
# File 'lib/evento/orchestrator.rb', line 13 def after_transaction_log_commit(name, &block) association = extractor.extract_transaction_log_association after_association_commit(association, name, &block) end |
#define_event_methods_on(target_klass, options = {}, &block) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/evento/orchestrator.rb', line 23 def define_event_methods_on(target_klass, = {}, &block) extractor.extract_events(state_machine: [:state_machine], devise: [:devise]) .reject { |event_name| target_klass.method_defined?(event_name) } .each do |event_name| target_klass.send(:define_method, event_name, &block) end return unless [:life_cycle] %i[create destroy update save].each do |event_name| target_klass.send(:define_method, event_name, &block) unless target_klass.method_defined?(event_name) end end |
#override_devise_notification(&block) ⇒ Object
37 38 39 40 |
# File 'lib/evento/orchestrator.rb', line 37 def override_devise_notification(&block) # As this is an override, ignore checking if it exists klass.define_method(:send_devise_notification, block) end |