Sha256: b56c4b3e9fe918eabacd1e0aa64cd5c5e6af7c1c474d17d6d03c1a0a6c3a813b

Contents?: true

Size: 1.15 KB

Versions: 1

Compression:

Stored size: 1.15 KB

Contents

module SlackRubyBotServer
  module Config
    extend self

    attr_accessor :logger
    attr_accessor :service_class
    attr_accessor :database_adapter
    attr_accessor :view_paths
    attr_accessor :oauth_scope

    def reset!
      self.logger = nil
      self.service_class = SlackRubyBotServer::Service
      self.oauth_scope = nil

      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 oauth_scope_s
      oauth_scope&.join('+')
    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

1 entries across 1 versions & 1 rubygems

Version Path
slack-ruby-bot-server-1.0.0 lib/slack-ruby-bot-server/config.rb