Sha256: ba0ac6167ddc644abf54db5e0792148ed7f166d03c6d086a2da58387d603d379
Contents?: true
Size: 1.43 KB
Versions: 2
Compression:
Stored size: 1.43 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) end def dup_for(new_owner) self.class.new(id: id, **options, owner: new_owner) end def resolve_class(name) end def notify?(method_name) handler_class.respond_to?(method_name) end def notify_now(handler, mid, *args, **kwargs) end def notify_later(handler, mid, *args, **kwargs) 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 ActiveDelivery::Base == owner.superclass return unless owner.superclass.respond_to?(handler_method) owner.superclass.public_send(handler_method) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
active_delivery-0.4.1 | lib/active_delivery/lines/base.rb |
active_delivery-0.4.0 | lib/active_delivery/lines/base.rb |