Sha256: 3c7337d09319d278ff35a603b2bde0db3c0ebcdb25cd7325a689237f8181ad92

Contents?: true

Size: 1.07 KB

Versions: 4

Compression:

Stored size: 1.07 KB

Contents

module SlackRubyBotServer
  module Config
    extend self

    attr_accessor :server_class
    attr_accessor :service_class
    attr_accessor :database_adapter
    attr_accessor :view_paths

    def reset!
      self.server_class = SlackRubyBotServer::Server
      self.service_class = SlackRubyBotServer::Service

      self.view_paths = [
        'views',
        'public',
        File.expand_path(File.join(__dir__, '../../public'))
      ]

      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

4 entries across 4 versions & 1 rubygems

Version Path
slack-ruby-bot-server-0.12.3 lib/slack-ruby-bot-server/config.rb
slack-ruby-bot-server-0.12.2 lib/slack-ruby-bot-server/config.rb
slack-ruby-bot-server-0.12.1 lib/slack-ruby-bot-server/config.rb
slack-ruby-bot-server-0.12.0 lib/slack-ruby-bot-server/config.rb