Module: SlackRubyBotServer::Config
Instance Attribute Summary collapse
-
#database_adapter ⇒ Object
Returns the value of attribute database_adapter.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#oauth_scope ⇒ Object
Returns the value of attribute oauth_scope.
-
#oauth_version ⇒ Object
Returns the value of attribute oauth_version.
-
#service_class ⇒ Object
Returns the value of attribute service_class.
-
#view_paths ⇒ Object
Returns the value of attribute view_paths.
Instance Method Summary collapse
- #activerecord? ⇒ Boolean
- #mongoid? ⇒ Boolean
- #oauth_access_method ⇒ Object
- #oauth_authorize_url ⇒ Object
- #oauth_scope_s ⇒ Object
- #reset! ⇒ Object
Instance Attribute Details
#database_adapter ⇒ Object
Returns the value of attribute database_adapter.
7 8 9 |
# File 'lib/slack-ruby-bot-server/config.rb', line 7 def database_adapter @database_adapter end |
#logger ⇒ Object
Returns the value of attribute logger.
5 6 7 |
# File 'lib/slack-ruby-bot-server/config.rb', line 5 def logger @logger end |
#oauth_scope ⇒ Object
Returns the value of attribute oauth_scope.
9 10 11 |
# File 'lib/slack-ruby-bot-server/config.rb', line 9 def oauth_scope @oauth_scope end |
#oauth_version ⇒ Object
Returns the value of attribute oauth_version.
10 11 12 |
# File 'lib/slack-ruby-bot-server/config.rb', line 10 def oauth_version @oauth_version end |
#service_class ⇒ Object
Returns the value of attribute service_class.
6 7 8 |
# File 'lib/slack-ruby-bot-server/config.rb', line 6 def service_class @service_class end |
#view_paths ⇒ Object
Returns the value of attribute view_paths.
8 9 10 |
# File 'lib/slack-ruby-bot-server/config.rb', line 8 def view_paths @view_paths end |
Instance Method Details
#activerecord? ⇒ Boolean
59 60 61 |
# File 'lib/slack-ruby-bot-server/config.rb', line 59 def activerecord? database_adapter == :activerecord end |
#mongoid? ⇒ Boolean
63 64 65 |
# File 'lib/slack-ruby-bot-server/config.rb', line 63 def mongoid? database_adapter == :mongoid end |
#oauth_access_method ⇒ Object
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/slack-ruby-bot-server/config.rb', line 44 def oauth_access_method case oauth_version when :v2 :oauth_v2_access when :v1 :oauth_access else raise ArgumentError, 'Invalid oauth_version, must be one of :v1 or v2.' end end |
#oauth_authorize_url ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/slack-ruby-bot-server/config.rb', line 33 def case oauth_version when :v2 'https://slack.com/oauth/v2/authorize' when :v1 'https://slack.com/oauth/authorize' else raise ArgumentError, 'Invalid oauth_version, must be one of :v1 or v2.' end end |
#oauth_scope_s ⇒ Object
55 56 57 |
# File 'lib/slack-ruby-bot-server/config.rb', line 55 def oauth_scope_s oauth_scope&.join(',') end |
#reset! ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/slack-ruby-bot-server/config.rb', line 12 def reset! self.logger = nil self.service_class = SlackRubyBotServer::Service self.oauth_scope = nil self.oauth_version = :v2 self.view_paths = [ 'views', 'public', File.(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 |