Class: Webhookdb::Message::FakeTransport

Inherits:
Transport
  • Object
show all
Extended by:
Webhookdb::MethodUtilities
Defined in:
lib/webhookdb/message/fake_transport.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Webhookdb::MethodUtilities

attr_predicate, attr_predicate_accessor, singleton_attr_accessor, singleton_attr_reader, singleton_attr_writer, singleton_method_alias, singleton_predicate_accessor, singleton_predicate_reader

Methods inherited from Transport

for, for!, #recipient, register_transport

Class Method Details

.reset!Object



19
20
21
22
23
# File 'lib/webhookdb/message/fake_transport.rb', line 19

def self.reset!
  self.sent_deliveries.clear
  self.disable_func = nil
  self.return_nil_on_send = false
end

Instance Method Details

#add_bodies(delivery, content) ⇒ Object



37
38
39
40
41
# File 'lib/webhookdb/message/fake_transport.rb', line 37

def add_bodies(delivery, content)
  bodies = []
  bodies << delivery.add_body(content: content.to_s, mediatype: "text/plain")
  return bodies
end

#send!(delivery) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
# File 'lib/webhookdb/message/fake_transport.rb', line 43

def send!(delivery)
  if Webhookdb::Message::FakeTransport.disable_func&.call(delivery)
    raise Webhookdb::Message::Transport::UndeliverableRecipient,
          "Did not deliver Delivery[#{delivery.id}] to #{delivery.to} because it was skipped by disable_func"
  end

  Webhookdb.logger.debug "Storing Delivery[%d] to %s as sent" % [delivery.id, delivery.to]
  Webhookdb::Message::FakeTransport.sent_deliveries << delivery
  return nil if Webhookdb::Message::FakeTransport.return_nil_on_send
  return "#{delivery.id}-#{SecureRandom.hex(6)}"
end

#serviceObject



29
30
31
# File 'lib/webhookdb/message/fake_transport.rb', line 29

def service
  return "fake"
end

#supports_layout?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/webhookdb/message/fake_transport.rb', line 33

def supports_layout?
  return true
end

#typeObject



25
26
27
# File 'lib/webhookdb/message/fake_transport.rb', line 25

def type
  return :fake
end