Sha256: 73f4447aa39e27ae4b8a05d11e45c52fc0125c12ff9554a66037225ddb99dca1

Contents?: true

Size: 727 Bytes

Versions: 4

Compression:

Stored size: 727 Bytes

Contents

# frozen_string_literal: true

module SlackRubyBot
  module Config
    extend self

    ATTRS = %i[token url aliases user user_id team team_id allow_bot_messages allow_message_loops logger].freeze
    attr_accessor(*ATTRS)

    def allow_bot_messages?
      !!allow_bot_messages
    end

    def allow_message_loops?
      !!allow_message_loops
    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
        raise ArgumentError, "Invalid value for #{key}: #{value}."
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
slackrb-0.17.1 lib/slack-ruby-bot/config.rb
slackrb-0.17.0 lib/slack-ruby-bot/config.rb
slack-ruby-bot-0.16.1 lib/slack-ruby-bot/config.rb
slack-ruby-bot-0.16.0 lib/slack-ruby-bot/config.rb