Sha256: 092cddc086f7d7247af6ab753c79d02b7640d4763aca04f10cfaf6c819e48dbb

Contents?: true

Size: 934 Bytes

Versions: 3

Compression:

Stored size: 934 Bytes

Contents

module SlackRubyBotServer
  module Config
    extend self

    attr_accessor :server_class
    attr_accessor :service_class
    attr_accessor :database_adapter

    def reset!
      self.server_class = SlackRubyBotServer::Server
      self.service_class = SlackRubyBotServer::Service
      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

3 entries across 3 versions & 1 rubygems

Version Path
slack-ruby-bot-server-0.11.1 lib/slack-ruby-bot-server/config.rb
slack-ruby-bot-server-0.11.0 lib/slack-ruby-bot-server/config.rb
slack-ruby-bot-server-0.10.0 lib/slack-ruby-bot-server/config.rb