Class: Slack::Messenger::PayloadMiddleware::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/slack-messenger/payload_middleware/base.rb

Direct Known Subclasses

At, Channels, FormatAttachments, FormatMessage

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(messenger, opts = {}) ⇒ Base

Returns a new instance of Base.



23
24
25
26
# File 'lib/slack-messenger/payload_middleware/base.rb', line 23

def initialize messenger, opts={}
  @messenger = messenger
  @options  = self.class.default_opts.merge opts
end

Instance Attribute Details

#messengerObject (readonly)

Returns the value of attribute messenger.



21
22
23
# File 'lib/slack-messenger/payload_middleware/base.rb', line 21

def messenger
  @messenger
end

#optionsObject (readonly)

Returns the value of attribute options.



21
22
23
# File 'lib/slack-messenger/payload_middleware/base.rb', line 21

def options
  @options
end

Class Method Details

.default_optsObject



16
17
18
# File 'lib/slack-messenger/payload_middleware/base.rb', line 16

def default_opts
  @default_opts ||= {}
end

.middleware_name(name) ⇒ Object



8
9
10
# File 'lib/slack-messenger/payload_middleware/base.rb', line 8

def middleware_name name
  PayloadMiddleware.register self, name.to_sym
end

.options(default_opts) ⇒ Object



12
13
14
# File 'lib/slack-messenger/payload_middleware/base.rb', line 12

def options default_opts
  @default_opts = default_opts
end

Instance Method Details

#call(_payload = {}) ⇒ Object

Raises:

  • (NoMethodError)


28
29
30
# File 'lib/slack-messenger/payload_middleware/base.rb', line 28

def call _payload={}
  raise NoMethodError, "method `call` not defined for class #{self.class}"
end