view_component_reflex 1.5.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aed815b44b0d4708ba9bb85e9a08912f15f4d66442432df5d0933866f66e3aba
4
- data.tar.gz: 96262b95434700007b142be8411d115dc50cdd0d5b94baf5200b582317ce858b
3
+ metadata.gz: 0d42e80a31d1a4a27c828f02fc584e9c5eb6660a6d5697e0db3a9631be358dec
4
+ data.tar.gz: 96450604f1d0965c104171a8b1d667f6d4dc38019e0c6434fd974ff80a3d9f26
5
5
  SHA512:
6
- metadata.gz: 8cdd11ece267f4cc206af3e12d3e62b4881fdde56afb28a23b078437448842eb54e7aa1da43a68dd4f071544bb360e95c15db2b4ea4599da9ee7e57e7887a2d8
7
- data.tar.gz: 64c8053422748319fd6460881170c3b5a9b84da0577180ebbf8a3dd3e62e5b1563c5d9e17c617de798141466f85894b42b281377aa553ff9a3840d9c522564d8
6
+ metadata.gz: deaf8859ae5816796b965ba5c7e1022032253f44fc1e6c94bcdda8dd481d20afb1319a63c99acc98e184908c5c0b299384e1b77cecef4cd5099263bc4f0d4606
7
+ data.tar.gz: 6da8e3668c5cf6f2dd64c770eada3b381669dd2dac2cf11dc65b2f9e7a94d4e7d450a563506459057642d0f97629d582d1935a9eef7bbf61acfc084402b2e1cd
data/README.md CHANGED
@@ -30,7 +30,7 @@ end
30
30
  # counter_component.html.erb
31
31
  <%= component_controller do %>
32
32
  <p><%= @count %></p>
33
- <button type="button" data-reflex="click->CounterComponentReflex#increment" data-key="<%= key %>">Click</button>
33
+ <%= reflex_tag :increment, :button, "Click" %>
34
34
  <% end %>
35
35
  ```
36
36
 
@@ -102,15 +102,23 @@ module ViewComponentReflex
102
102
  helpers.controller.instance_variable_get(:@stimulus_reflex)
103
103
  end
104
104
 
105
- def component_controller(opts = {}, &blk)
105
+ def component_controller(opts_or_tag = :div, opts = {}, &blk)
106
106
  self.class.init_stimulus_reflex
107
107
  init_key
108
- opts[:data] = {
108
+
109
+ tag = :div
110
+ if opts_or_tag.is_a? Hash
111
+ options = opts_or_tag
112
+ else
113
+ tag = opts_or_tag
114
+ options = opts
115
+ end
116
+ options[:data] = {
109
117
  controller: self.class.stimulus_controller,
110
118
  key: key,
111
- **(opts[:data] || {})
119
+ **(options[:data] || {})
112
120
  }
113
- content_tag :div, capture(&blk), opts
121
+ content_tag tag, capture(&blk), options
114
122
  end
115
123
 
116
124
  # key is required if you're using state
@@ -126,7 +134,7 @@ module ViewComponentReflex
126
134
  end
127
135
 
128
136
  def reflex_tag(reflex, name, content_or_options_with_block = nil, options = nil, escape = true, &block)
129
- action, method = reflex.split("->")
137
+ action, method = reflex.to_s.split("->")
130
138
  if method.nil?
131
139
  method = action
132
140
  action = "click"
@@ -1,3 +1,3 @@
1
1
  module ViewComponentReflex
2
- VERSION = '1.5.0'
2
+ VERSION = '1.6.0'
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: 1.5.0
4
+ version: 1.6.0
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-06-22 00:00:00.000000000 Z
11
+ date: 2020-06-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails