Module: Breacan::Configurable
Constant Summary collapse
- OPTIONS_KEYS =
i( access_token team api_endpoint web_endpoint user_agent media_type proxy middleware )
Class Method Summary collapse
Instance Method Summary collapse
- #api_endpoint ⇒ Object
- #configure {|_self| ... } ⇒ Object
- #options ⇒ Object
- #reset! ⇒ Object (also: #setup)
- #web_endpoint ⇒ Object
Class Method Details
.keys ⇒ Object
20 21 22 |
# File 'lib/breacan/configurable.rb', line 20 def keys @keys ||= OPTIONS_KEYS end |
Instance Method Details
#api_endpoint ⇒ Object
29 30 31 |
# File 'lib/breacan/configurable.rb', line 29 def api_endpoint File.join(@api_endpoint, '') end |
#configure {|_self| ... } ⇒ Object
25 26 27 |
# File 'lib/breacan/configurable.rb', line 25 def configure yield self end |
#options ⇒ Object
61 62 63 64 65 |
# File 'lib/breacan/configurable.rb', line 61 def Hash[Breacan::Configurable.keys.map { |key| [key, instance_variable_get(:"@#{key}")] }] end |
#reset! ⇒ Object Also known as: setup
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/breacan/configurable.rb', line 37 def reset! builder = if defined? Faraday::RackBuilder Faraday::RackBuilder else Faraday::Builder end @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' = { headers: { accept: media_type, user_agent: user_agent } } @proxy = ENV['BREACAN_PROXY'] @middleware = builder.new { |c| c.adapter Faraday.default_adapter c.response :breacan_custom } self end |
#web_endpoint ⇒ Object
33 34 35 |
# File 'lib/breacan/configurable.rb', line 33 def web_endpoint File.join(@web_endpoint, '') end |