module Slackbot::Rails

Constants

VERSION

Private Instance Methods

build_message(action) click to toggle source
# File lib/slackbot/rails.rb, line 70
def build_message(action)
  begin
  message = slackbot_rails_options[:message][action.to_sym]

  evaluate = message.scan(/{(.*?)}/).flatten
  values = evaluate.inject({}) {|h,e| h.merge!(e => e.to_s.split('.').inject(self) {|o, a| o.try(a)})}
  ready = message
  values.each do |k,v|
    ready = ready.gsub!("{#{k}}", v.to_s)
  end
  
  rescue Exception => e
  logger.fatal e.message
  end
  ready
end
push_create_notification_to_bot() click to toggle source
# File lib/slackbot/rails.rb, line 48
def push_create_notification_to_bot
  begin
    Thread.new do
      self.class.push_to_bot build_message('create')
    end
  rescue Exception => e
      logger.fatal "[Slackbot::Rails] Something went wrong with pushing to the bot:"
      logger.fatal "[Slackbot::Rails] #{e}"
    end
end
push_update_notification_to_bot() click to toggle source
# File lib/slackbot/rails.rb, line 59
def push_update_notification_to_bot
  begin
    Thread.new do
      self.class.push_to_bot build_message('update')
    end
  rescue Exception => e
      logger.fatal "[Slackbot::Rails] Something went wrong with pushing to the bot:"
      logger.fatal "[Slackbot::Rails] #{e}"
    end
end