Sha256: ff75b33546824ef342e952cfd394b8cd83d9fa8c6f222785f1385b2554d80645
Contents?: true
Size: 1.5 KB
Versions: 1
Compression:
Stored size: 1.5 KB
Contents
# frozen_string_literal: true module ActiveDelivery module Lines class Base attr_reader :id, :options attr_accessor :owner attr_writer :handler_class def initialize(id:, owner:, **options) @id = id @owner = owner @options = options.tap(&:freeze) @resolver = options[:resolver] end def dup_for(new_owner) self.class.new(id: id, **options, owner: new_owner) end def resolve_class(name) resolver&.call(name) end def notify?(method_name) handler_class.respond_to?(method_name) end def notify_now(handler, mid, ...) end def notify_later(handler, mid, ...) end def notify(mid, *args, params:, sync:, **kwargs) clazz = params.empty? ? handler_class : handler_class.with(**params) sync ? notify_now(clazz, mid, *args, **kwargs) : notify_later(clazz, mid, *args, **kwargs) end def handler_class return @handler_class if instance_variable_defined?(:@handler_class) return @handler_class = nil if owner.abstract_class? @handler_class = resolve_class(owner.name) || superclass_handler end private def superclass_handler handler_method = "#{id}_class" return if owner.superclass == ActiveDelivery::Base return unless owner.superclass.respond_to?(handler_method) owner.superclass.public_send(handler_method) end attr_reader :resolver end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
active_delivery-1.0.0.rc2 | lib/.rbnext/3.1/active_delivery/lines/base.rb |