Class: ActionMessenger::Base
- Inherits:
-
AbstractController::Base
- Object
- AbstractController::Base
- ActionMessenger::Base
- Includes:
- AbstractController::Helpers, AbstractController::Logger, AbstractController::Rendering, Rescuable, ActionView::Layouts
- Defined in:
- lib/action_messenger/base.rb
Instance Attribute Summary collapse
-
#caller_method_name ⇒ Object
readonly
Returns the value of attribute caller_method_name.
Class Method Summary collapse
Instance Method Summary collapse
-
#message_to_slack(channel:, options: {}) ⇒ Object
message to slack.
-
#upload_file_to_slack(channels:, file:, options: {}) ⇒ Object
upload file to slack.
Methods included from Rescuable
Instance Attribute Details
#caller_method_name ⇒ Object (readonly)
Returns the value of attribute caller_method_name.
36 37 38 |
# File 'lib/action_messenger/base.rb', line 36 def caller_method_name @caller_method_name end |
Class Method Details
.logger ⇒ Object
15 16 17 |
# File 'lib/action_messenger/base.rb', line 15 def logger ActionMessenger.config.logger || (defined?(Rails) ? Rails.logger : nil) end |
Instance Method Details
#message_to_slack(channel:, options: {}) ⇒ Object
message to slack
ex. message_to_slack(channel: ‘#general’, options: ‘sample’)
46 47 48 49 50 51 52 53 54 |
# File 'lib/action_messenger/base.rb', line 46 def (channel:, options: {}) @caller_method_name = caller[0][/`([^']*)'/, 1] = apply_defaults() = nil ActiveSupport::Notifications.instrument('message_to_slack.action_messenger', channel: channel, body: [:text]) do = slack_client.(channel, ) end end |
#upload_file_to_slack(channels:, file:, options: {}) ⇒ Object
upload file to slack
63 64 65 66 67 68 69 |
# File 'lib/action_messenger/base.rb', line 63 def upload_file_to_slack(channels: ,file: ,options: {}) upload_file = nil ActiveSupport::Notifications.instrument('upload_file_to_slack.action_messenger', channels: channels) do upload_file = slack_client.upload_file(channels, file, ) end upload_file end |