Class: ActiveNotifier::AbstractAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/active_notifier/adapters/abstract_adapter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(adapter_class) ⇒ AbstractAdapter

Returns a new instance of AbstractAdapter.



5
6
7
# File 'lib/active_notifier/adapters/abstract_adapter.rb', line 5

def initialize(adapter_class)
  @adapter = adapter_class.new
end

Instance Attribute Details

#adapterObject (readonly)

Returns the value of attribute adapter.



3
4
5
# File 'lib/active_notifier/adapters/abstract_adapter.rb', line 3

def adapter
  @adapter
end

Instance Method Details

#notify(token, type, message, **options) ⇒ Object

This method is abstract.

Implement through setting a real adapter, like :dingtalk

Notify message

Parameters:

  • token (String)

    Channel webhook token

  • type (Symbol)

    Message type

  • message (String)

    Message body

  • options (Hash)

    Adapter message options, some adapters require some another options

Raises:

See Also:

  • for usage


20
21
22
# File 'lib/active_notifier/adapters/abstract_adapter.rb', line 20

def notify(token, type, message, **options)
  adapter.notify(token, type, message, **options)
end