Sha256: f15804d7aa774518415a585fee5e214a1a7c77362570689911b6b297d7afe5ea
Contents?: true
Size: 1.38 KB
Versions: 2
Compression:
Stored size: 1.38 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) end def notify_later(handler, mid, *args) end def notify(mid, *args, params:, sync:) clazz = params.empty? ? handler_class : handler_class.with(params) sync ? notify_now(clazz, mid, *args) : notify_later(clazz, mid, *args) 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.3.1 | lib/active_delivery/lines/base.rb |
active_delivery-0.3.0 | lib/active_delivery/lines/base.rb |