Sha256: 3619a0217baed3586f52c1c75027f9d96964528e83afb4a907fb084e8618d636
Contents?: true
Size: 760 Bytes
Versions: 3
Compression:
Stored size: 760 Bytes
Contents
module SlackRubyBot module Config extend self ATTRS = [:token, :url, :aliases, :user, :user_id, :team, :team_id, :allow_message_loops, :send_gifs].freeze attr_accessor(*ATTRS) def allow_message_loops? allow_message_loops end def send_gifs? v = boolean_from_env('SLACK_RUBY_BOT_SEND_GIFS') v.nil? ? (send_gifs.nil? || send_gifs) : v end def reset! ATTRS.each { |attr| send("#{attr}=", nil) } end private def boolean_from_env(key) value = ENV[key] case value when nil nil when 0, 'false', 'no' false when 1, 'true', 'yes' true else fail ArgumentError, "Invalid value for #{key}: #{value}." end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
slack-ruby-bot-0.7.0 | lib/slack-ruby-bot/config.rb |
slack-ruby-bot-0.6.2 | lib/slack-ruby-bot/config.rb |
slack-ruby-bot-0.6.1 | lib/slack-ruby-bot/config.rb |