Created
November 1, 2019 06:18
-
-
Save mitsuhirookuno/c27157de153f200cf10345c0f1ce739b to your computer and use it in GitHub Desktop.
良い実装か?は置いていて、controllerのconcernsをmodelから利用するやつ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module SlackHelper | |
extend ActiveSupport::Concern | |
# メッセージを通知します | |
def self.send_to_slack(message, channel:, mentions: nil, icon: ':fukurouchan:') | |
mentions_line = SlackHelper.create_mentions_line(mentions) | |
SlackHelper.send_core(mentions_line + message, channel, icon_emoji: icon) | |
end | |
delegate :send_to_slack, to: SlackHelper |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Hoge < ApplicationRecord | |
def foobar | |
SlackHelper.send_to_slack('test model', channel: 'infra') | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment