view_component_reflex 3.0.4 → 3.0.5

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: eb02765f889a8b562adc0dc0d5d4413c9f9d4a03dee0bf4250f2efc5469e6927
4
- data.tar.gz: fc2cdce4de4712ab91820ede8ba124b1ec74757a1a66f488148d43fb31d7e409
3
+ metadata.gz: 0c063a5b69263cf48e6a92937e65a73cd1a2c5e00577734f62b7cbf6186604d3
4
+ data.tar.gz: 26ec1a060c0283a906df2bcda4cd11110bb31ebe69e9d5c741cf568d6dabd7de
5
5
  SHA512:
6
- metadata.gz: a8073aab28996f5f1941fd3574140d64b1e583c75083031162b373269a8d226b9d26513cf891507de43d215daf044d0e2586a31b2ac46b9c4c693d9f319af877
7
- data.tar.gz: dc81f869b0c4648eb3cf63276872acad47b0563d3a19f3f0c90c1db4474ab7995798a735c878afe319576f5b04655de501b7e599f32b21faefaf8603c5de0089
6
+ metadata.gz: b7f55e4e85f42a9c9b0044710f8f2c295e0c13350bfc26f1c940626b581e68a851feb1c7cf4c54124a7e96ac9ade6565b1e3361f789e0efbc16644c78bc906b2
7
+ data.tar.gz: aa24fa075eae92847e04931a1278b20358472fc9fdb00079bb1f0b774d84f5a3a047f90d61e42295a578999a7c69ec12e152847d77ecf6a4236554d4b4c38605
@@ -57,7 +57,7 @@ module ViewComponentReflex
57
57
  def component_controller(opts_or_tag = :div, opts = {}, &blk)
58
58
  init_key
59
59
 
60
- tag = :div
60
+ tag = :di
61
61
  options = if opts_or_tag.is_a? Hash
62
62
  opts_or_tag
63
63
  else
@@ -1,5 +1,6 @@
1
1
  require "stimulus_reflex"
2
2
  require 'view_component_reflex/reflex_factory'
3
+ require "view_component_reflex/state_adapter/base"
3
4
  require "view_component_reflex/state_adapter/session"
4
5
  require "view_component_reflex/state_adapter/memory"
5
6
  require "view_component_reflex/state_adapter/redis"
@@ -0,0 +1,18 @@
1
+ module ViewComponentReflex
2
+ module StateAdapter
3
+ class Base
4
+
5
+ private
6
+
7
+ def self.extract_id(request)
8
+ session = request&.session
9
+ if session.respond_to? :id
10
+ session.id.to_s
11
+ else
12
+ nil
13
+ end
14
+ end
15
+
16
+ end
17
+ end
18
+ end
@@ -1,7 +1,7 @@
1
1
  VIEW_COMPONENT_REFLEX_MEMORY_STATE = {}
2
2
  module ViewComponentReflex
3
3
  module StateAdapter
4
- class Memory
4
+ class Memory < Base
5
5
  def self.state(request, key)
6
6
  id = extract_id(request)
7
7
 
@@ -28,17 +28,6 @@ module ViewComponentReflex
28
28
  def self.wrap_write_async
29
29
  yield
30
30
  end
31
-
32
- private
33
-
34
- def self.extract_id(request)
35
- session = request&.session
36
- if session.respond_to? :id
37
- session.id.to_s
38
- else
39
- nil
40
- end
41
- end
42
31
  end
43
32
  end
44
33
  end
@@ -10,7 +10,7 @@
10
10
 
11
11
  module ViewComponentReflex
12
12
  module StateAdapter
13
- class Redis
13
+ class Redis < Base
14
14
  attr_reader :client, :ttl
15
15
 
16
16
  def initialize(redis_opts:, ttl: 3600)
@@ -67,8 +67,9 @@ module ViewComponentReflex
67
67
  end
68
68
 
69
69
  def get_key(request, key)
70
- "#{request.session.id.to_s}_#{key}_session_reflex_redis"
70
+ id = Redis.extract_id(request)
71
+ "#{id}_#{key}_session_reflex_redis"
71
72
  end
72
73
  end
73
74
  end
74
- end
75
+ end
@@ -1,6 +1,6 @@
1
1
  module ViewComponentReflex
2
2
  module StateAdapter
3
- class Session
3
+ class Session < Base
4
4
  def self.state(request, key)
5
5
  request.session[key] ||= {}
6
6
  end
@@ -1,3 +1,3 @@
1
1
  module ViewComponentReflex
2
- VERSION = '3.0.4'
2
+ VERSION = '3.0.5'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: view_component_reflex
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.4
4
+ version: 3.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua LeBlanc
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-12-19 00:00:00.000000000 Z
11
+ date: 2021-01-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -87,6 +87,7 @@ files:
87
87
  - lib/view_component_reflex/engine.rb
88
88
  - lib/view_component_reflex/reflex.rb
89
89
  - lib/view_component_reflex/reflex_factory.rb
90
+ - lib/view_component_reflex/state_adapter/base.rb
90
91
  - lib/view_component_reflex/state_adapter/memory.rb
91
92
  - lib/view_component_reflex/state_adapter/redis.rb
92
93
  - lib/view_component_reflex/state_adapter/session.rb