module Breacan::Configurable

Constants

OPTIONS_KEYS

Public Class Methods

keys() click to toggle source
# File lib/breacan/configurable.rb, line 22
def keys
  @keys ||= OPTIONS_KEYS
end

Public Instance Methods

api_endpoint() click to toggle source
# File lib/breacan/configurable.rb, line 31
def api_endpoint
  File.join(@api_endpoint, '')
end
configure() { |self| ... } click to toggle source
# File lib/breacan/configurable.rb, line 27
def configure
  yield self
end
default_builder() click to toggle source
# File lib/breacan/configurable.rb, line 61
def default_builder
  builder = if defined? Faraday::RackBuilder
              Faraday::RackBuilder
            else
              Faraday::Builder
            end

  builder.new do |c|
    c.response :breacan_custom
    c.adapter Faraday.default_adapter
  end
end
default_serializer() click to toggle source
# File lib/breacan/configurable.rb, line 57
def default_serializer
  Sawyer::Serializer.any_json
end
options() click to toggle source
# File lib/breacan/configurable.rb, line 74
def options
  Hash[Breacan::Configurable.keys.map { |key|
    [key, instance_variable_get(:"@#{key}")]
  }]
end
reset!() click to toggle source
# File lib/breacan/configurable.rb, line 39
def reset!

  @access_token       = ENV['BREACAN_ACCESS_TOKEN']
  @team               = ENV['BREACAN_TEAM']
  @api_endpoint       = ENV['BREACAN_API_ENDPOINT'] || 'https://slack.com/api/'
  @web_endpoint       = ENV['BREACAN_WEB_ENDPOINT'] || "https://#{@team}.slack.com/"
  @user_agent         = "Breacan Ruby Gem #{Breacan::VERSION}"
  @media_type         = 'application/json'
  @connection_options = { headers: { accept: media_type, user_agent: user_agent } }
  @proxy              = ENV['BREACAN_PROXY']
  @middleware         = default_builder
  @serializer         = default_serializer
  @auto_paginate      = !!ENV['BREACAN_AUTO_PAGINATE']

  self
end
Also aliased as: setup
setup()
Alias for: reset!
web_endpoint() click to toggle source
# File lib/breacan/configurable.rb, line 35
def web_endpoint
  File.join(@web_endpoint, '')
end