lib/slacked/slack_post.rb in slacked-0.8.0 vs lib/slacked/slack_post.rb in slacked-0.9.0
- old
+ new
@@ -6,11 +6,11 @@
icon_emoji: SLACK_PROFILE_IMAGE
}
class << self
def post message = ENV[SLACK_DEFAULT_MESSAGE_KEY]
- return false if message.nil? || message.empty?
+ return false if message.nil? || message.empty? || disabled?
notifier = slack_notifier
notifier.ping message, SLACK_CONFIG
end
def post_async message
@@ -19,11 +19,21 @@
defined?(ActiveRecord) ? ActiveRecord::Base.connection.close : nil
result
end
end
+ def disabled?
+ return false unless rails?
+ rails_config = Rails.application.config
+ rails_config.respond_to?(:slacked_disabled) && rails_config.slacked_disabled
+ end
+
private
def slack_notifier webhook_url = ENV[SLACK_WEBHOOK_URL_KEY]
Slack::Notifier.new webhook_url
+ end
+
+ def rails?
+ defined?(Rails)
end
end
end