Class: ActionMessageTexter::MessageDelivery

Inherits:
Delegator
  • Object
show all
Defined in:
lib/action_message_texter/message_delivery.rb

Overview

分派工作

Instance Method Summary collapse

Constructor Details

#initialize(texter_class, action, *args) ⇒ MessageDelivery

Returns a new instance of MessageDelivery.



6
7
8
9
10
# File 'lib/action_message_texter/message_delivery.rb', line 6

def initialize(texter_class, action, *args)
  @texter_class = texter_class
  @action = action
  @args = args
end

Instance Method Details

#__getobj__Object



22
23
24
# File 'lib/action_message_texter/message_delivery.rb', line 22

def __getobj__
  @message ||= processed_messenger.message
end

#__setobj__(message) ⇒ Object



26
27
28
# File 'lib/action_message_texter/message_delivery.rb', line 26

def __setobj__(message)
  @message = message
end

#deliver_later(options = {}) ⇒ Object



18
19
20
# File 'lib/action_message_texter/message_delivery.rb', line 18

def deliver_later(options = {})
  enqueue_delivery :deliver_now, options
end

#deliver_nowObject



12
13
14
15
16
# File 'lib/action_message_texter/message_delivery.rb', line 12

def deliver_now
  processed_messenger.handle_exceptions do
    message.deliver
  end
end

#messageObject



30
31
32
# File 'lib/action_message_texter/message_delivery.rb', line 30

def message
  __getobj__
end

#processed?Boolean

是否送出

Returns:

  • (Boolean)


35
36
37
# File 'lib/action_message_texter/message_delivery.rb', line 35

def processed?
  @processed_messenger || @message
end