Module: FtShared
- Defined in:
- lib/ft_gem/shared/ft_shared.rb
Class Method Summary collapse
Class Method Details
.all_toggles ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/ft_gem/shared/ft_shared.rb', line 12 def all_toggles Rails.cache.fetch('all-feature-toggles', expires_in: 1.minute) do JSON.parse(HTTP.headers(authentication_header).get("#{ENV['SITE_URL']}/service/ft/api/v1/feature-toggles/"))['data'] end rescue StandardError => e Rails.logger.error "FtHelper::all_toggles error #{e.backtrace}" {} end |
.authentication_header ⇒ Object
21 22 23 |
# File 'lib/ft_gem/shared/ft_shared.rb', line 21 def authentication_header { Authorization: "Bearer #{MumsnetJWT.tokenify}" } end |
.fetch(name:) ⇒ Object
3 4 5 6 7 8 9 10 |
# File 'lib/ft_gem/shared/ft_shared.rb', line 3 def fetch(name:) Rails.cache.fetch("feature-toggle-#{name}", expires_in: 1.minute) do JSON.parse(HTTP.headers(authentication_header).get("#{ENV['SITE_URL']}/service/ft/api/v1/feature-toggles/status", params: { name: name }).body.to_s)['data'] end rescue StandardError => e Rails.logger.error "FtHelper::fetch error #{e.backtrace}" nil end |