Class: ActionMessage::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/action_message/message.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMessage

Returns a new instance of Message.



8
9
10
# File 'lib/action_message/message.rb', line 8

def initialize
  @adapter = Adapters.adapter
end

Instance Attribute Details

#actionObject

Returns the value of attribute action.



5
6
7
# File 'lib/action_message/message.rb', line 5

def action
  @action
end

#adapterObject (readonly)

Returns the value of attribute adapter.



6
7
8
# File 'lib/action_message/message.rb', line 6

def adapter
  @adapter
end

#argsObject

Returns the value of attribute args.



5
6
7
# File 'lib/action_message/message.rb', line 5

def args
  @args
end

#bodyObject

Returns the value of attribute body.



5
6
7
# File 'lib/action_message/message.rb', line 5

def body
  @body
end

#debugObject

Returns the value of attribute debug.



5
6
7
# File 'lib/action_message/message.rb', line 5

def debug
  @debug
end

#toObject

Returns the value of attribute to.



5
6
7
# File 'lib/action_message/message.rb', line 5

def to
  @to
end

Instance Method Details

#debug?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/action_message/message.rb', line 12

def debug?
  !!@debug
end

#deliverObject



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/action_message/message.rb', line 16

def deliver
  if debug?
    # TODO: add log
    return nil
  elsif Interceptor.registered_for?(self)
    # TODO: add log
    return nil   
  else
    # TODO: add logger 'Sending message from "number" to "number"'
    adapter.send_message(body, to: to)
  end
end