Sha256: cfe57e26b8b1534536d0164d65b05db572e4c7f30ef9a9cd36f067ea636cf7e9

Contents?: true

Size: 892 Bytes

Versions: 5

Compression:

Stored size: 892 Bytes

Contents

module SlackRubyBotServer
  module Config
    extend self

    attr_accessor :server_class
    attr_accessor :ping
    attr_accessor :database_adapter

    def reset!
      self.ping = nil
      self.server_class = SlackRubyBotServer::Server
      self.database_adapter = if defined?(::Mongoid)
                                :mongoid
                              elsif defined?(::ActiveRecord)
                                :activerecord
                              else
                                raise 'One of "mongoid" or "activerecord" is required.'
                              end
    end

    def activerecord?
      database_adapter == :activerecord
    end

    def mongoid?
      database_adapter == :mongoid
    end

    reset!
  end

  class << self
    def configure
      block_given? ? yield(Config) : Config
    end

    def config
      Config
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
slack-ruby-bot-server-0.8.3 lib/slack-ruby-bot-server/config.rb
slack-ruby-bot-server-0.8.2 lib/slack-ruby-bot-server/config.rb
slack-ruby-bot-server-0.8.1 lib/slack-ruby-bot-server/config.rb
slack-ruby-bot-server-0.8.0 lib/slack-ruby-bot-server/config.rb
slack-ruby-bot-server-0.7.0 lib/slack-ruby-bot-server/config.rb