module Realm::Mixins::Reactive
Protected Instance Methods
run(command, params = {})
click to toggle source
# File lib/realm/mixins/reactive.rb, line 8 def run(command, params = {}) parts = command.to_s.split('.') parts.prepend(aggregate) if parts.size == 1 && respond_to?(:aggregate) && aggregate @runtime.run(parts.join('.'), params.to_h) end
trigger(event_type, attributes = {})
click to toggle source
# File lib/realm/mixins/reactive.rb, line 14 def trigger(event_type, attributes = {}) attributes = attributes.to_h head = { origin: origin(caller_locations(1, 1)) }.merge(attributes.fetch(:head, {})) final_attrs = attributes.merge(head: head) final_attrs[:cause] ||= context[:cause] if context.key?(:cause) @runtime.trigger(event_type, final_attrs) end
Private Instance Methods
origin(backtrace)
click to toggle source
Detects the class and method from which this event is triggered
# File lib/realm/mixins/reactive.rb, line 25 def origin(backtrace) [self.class.name, backtrace[0].to_s.match(/`([^']+)'/)&.then { |m| "##{m[1]}" }].join end