Skip to content

Commit

Permalink
Make configuration threadsafe [ch23375] (#73)
Browse files Browse the repository at this point in the history
* Make config threadsafe

* Update README

* Bump version
  • Loading branch information
swember authored Jul 10, 2020
1 parent 0ad15e6 commit 0df3f2d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ ChartMogul.account_token = '<Account key goes here>'
ChartMogul.secret_key = '<Secret key goes here>'
```

Configuration is threadsafe and applied only to the current thread.

Test your authentication:
```ruby
ChartMogul::Ping.ping
Expand Down
5 changes: 4 additions & 1 deletion lib/chartmogul.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,11 @@ module ChartMogul
class << self
extend ConfigAttributes

CONFIG_THREAD_KEY = 'chartmogul_ruby.config'

def config
@config ||= ChartMogul::Configuration.new
Thread.current[CONFIG_THREAD_KEY] = ChartMogul::Configuration.new if Thread.current[CONFIG_THREAD_KEY].nil?
Thread.current[CONFIG_THREAD_KEY]
end

config_accessor :account_token
Expand Down
2 changes: 1 addition & 1 deletion lib/chartmogul/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module ChartMogul
VERSION = '1.5.2'
VERSION = '1.6.0'
end

0 comments on commit 0df3f2d

Please sign in to comment.