Skip to content

Commit

Permalink
Merge pull request #32 from paladinsoftware/use-request-store
Browse files Browse the repository at this point in the history
use RequestStore instead of Thread[:current]
  • Loading branch information
tobstarr authored May 31, 2017
2 parents b0a27bf + 3578ac9 commit d1ee11a
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions lib/phraseapp-in-context-editor-ruby.rb
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
# -*- encoding : utf-8 -*-
require 'phraseapp-ruby'
require 'request_store'

module PhraseApp
module InContextEditor
autoload :Config, 'phraseapp-in-context-editor-ruby/config'

class << self
def config
Thread.current[:phraseapp_config] ||= PhraseApp::InContextEditor::Config.new
RequestStore.store[:phraseapp_config] ||= PhraseApp::InContextEditor::Config.new
end

def config=(value)
Thread.current[:phraseapp_config] = value
RequestStore.store[:phraseapp_config] = value
end

def backend
Expand Down
2 changes: 1 addition & 1 deletion lib/phraseapp-in-context-editor-ruby/key_names_cache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def key_name_precached?(key_name)
end

def cache
Thread.current[:phraseapp_cache] ||= PhraseApp::InContextEditor::Cache.new
RequestStore.store[:phraseapp_cache] ||= PhraseApp::InContextEditor::Cache.new
end
end
end
Expand Down
1 change: 1 addition & 0 deletions phraseapp-in-context-editor-ruby.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Gem::Specification.new do |s|
end
s.add_dependency('i18n', '>= 0.6')
s.add_dependency('phraseapp-ruby', '~> 1.3')
s.add_dependency('request_store', '~> 1.3')
s.add_development_dependency('rspec', '~> 3.2')
s.add_development_dependency('webmock', '~> 1.21')
s.add_development_dependency('vcr', '~> 2.9')
Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

config.after(:each) do |example|
PhraseApp::InContextEditor::Config.reset_to_defaults!
Thread.current[:phraseapp_config] = nil
RequestStore.store[:phraseapp_config] = nil
end
end

Expand Down

0 comments on commit d1ee11a

Please sign in to comment.