spree_request_store 3.1.3 → 3.1.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 265a4ec7acd72ee9b0357e4e2e2d57132000a08583c7518350be5e0746713fd2
4
- data.tar.gz: d5aa5592e3aaa5eae8013e355439bb4fb87bd6d61bc3a70f2c03b74abe781f92
3
+ metadata.gz: 3cc4c7bf36266ccc225498522157020cb8efd999276f4f010990d5840ba9a490
4
+ data.tar.gz: e3abb7abfe635a2be455847451757e1fb7b3394f6dc77f4b1c06f5e10063cb18
5
5
  SHA512:
6
- metadata.gz: 464397a9a65cb7c169ffd1a0a07fb3647b398074150b5333a2eedb7d795f404c22a7c743536621b49eaa3d34535da61d8c7a09c28378bf38f10866f42deeec19
7
- data.tar.gz: dfda06498f4a75d881539f835c82d9fe77e8bc3ccf541c8a8c88f7aa540da5f7b66c05f4f3d91b1609b6bb29fd57e1cc896c9de93385e3345a7e3d97eb29f71f
6
+ metadata.gz: 5b9cf0d574537879bdca7737f4a03b3dd8c6f70848ed7eadd08be3b293f1caa1ab7cb8370455c051305e8ddc36cb5c56ad9b4112a7fc188d66845a926604f042
7
+ data.tar.gz: ef13544a10358bbba68269f74fa3d1f9f8754c20f2965897803d6286cd20500538ed7821e7177f1cc3feeb9dafdf9de28b179ed4994d632fb54f135f61683157
@@ -0,0 +1,11 @@
1
+ require 'request_store'
2
+
3
+ Spree::BaseController.class_eval do
4
+ prepend_before_action :set_current_info
5
+
6
+ def set_current_info
7
+ RequestStore.store[:current_user] = spree_current_user || current_spree_user
8
+ RequestStore.store[:current_currency] = current_currency
9
+ RequestStore.store[:current_store] = current_store
10
+ end
11
+ end
@@ -0,0 +1,30 @@
1
+ require 'request_store'
2
+
3
+ Spree::Store.class_eval do
4
+ def self.current_user
5
+ RequestStore.store[:current_user]
6
+ end
7
+
8
+ def self.current_currency
9
+ RequestStore.store[:current_currency] || Spree::Config[:currency]
10
+ end
11
+
12
+ def self.current_store
13
+ RequestStore.store[:current_store] || Spree::Store.current
14
+ end
15
+
16
+ def self.with_store(store)
17
+ RequestStore.store[:current_store] = store
18
+ yield
19
+ end
20
+
21
+ def self.with_currency(currency)
22
+ RequestStore.store[:current_currency] = currency
23
+ yield
24
+ end
25
+
26
+ def self.with_user(user)
27
+ RequestStore.store[:current_user] = user
28
+ yield
29
+ end
30
+ end
@@ -10,7 +10,7 @@ module SpreeRequestStore
10
10
  module VERSION
11
11
  MAJOR = 3
12
12
  MINOR = 1
13
- TINY = 3
13
+ TINY = 7
14
14
 
15
15
  STRING = [MAJOR, MINOR, TINY].compact.join('.')
16
16
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree_request_store
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.3
4
+ version: 3.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Charles Wong
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-08-28 00:00:00.000000000 Z
11
+ date: 2018-09-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: spree_core
@@ -311,6 +311,8 @@ extensions: []
311
311
  extra_rdoc_files: []
312
312
  files:
313
313
  - README.md
314
+ - app/controllers/spree/base_controller_decorator.rb
315
+ - app/models/spree/store_decorator.rb
314
316
  - lib/generators/spree_request_store/install/install_generator.rb
315
317
  - lib/spree_request_store.rb
316
318
  - lib/spree_request_store/engine.rb