view_component_reflex 3.3.15 → 3.3.16

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: fbdb0c548ac99d17f7f374cbfdcc6cab153261dd17ca523c5efe35d9a83de997
4
- data.tar.gz: 1f28b2518774b015b15a51de621a0386af87ab5611879b05deae794edba15be7
3
+ metadata.gz: e8dea2221ccd4d6ffabc20687fcab334820ded3d9d40d14242f132c730942126
4
+ data.tar.gz: 06e5f08ea176338c87b63ade59d4fc5e9a364b0f53e83410f57372ba3f2fdfdd
5
5
  SHA512:
6
- metadata.gz: 3ddbf559fa51e0d6e071332a91904867c1e8fc729328f978fcfbbc8c0e4d81b41f4c8c22d88af48a9cd8dfc3eca3f6c95682fa2efab3bf7428549a2e2b370bf5
7
- data.tar.gz: d28ee104774a8638e8402d36176cd6fdd39268916a03933eec0f6773cefa934f80e99f5625afbc2a6e15f29dfe966ba3bdd9a307c55f9900ea91cf8a78aaa212
6
+ metadata.gz: '029140d0e31153061345aa774ca8a13b67615323411b378871f4ea94e05fbb4a112121a6b98c6d2ae3d5d3b267d58d0951869f41ba33fab8f2442e1650c9e296'
7
+ data.tar.gz: 576d8bc75bfe2a2250a3d874463276d50b8cdc2fa8092461cdf5738e4bd3c0a166ea131f5c01758226dcf400b3bb708e862e49bad6f3e07f4ebc81ebe2a65568
data/README.md CHANGED
@@ -233,6 +233,34 @@ def after_state_initialized(parameters_changed)
233
233
  end
234
234
  ```
235
235
 
236
+ ### reflex_methods
237
+
238
+ By default, all public instance methods are available as reflex methods. You can override this to explicitly define which methods should be available as reflexes:
239
+
240
+ ```ruby
241
+ class MyComponent < ViewComponentReflex::Component
242
+ def self.reflex_methods
243
+ [:increment, :decrement, :reset]
244
+ end
245
+
246
+ def increment
247
+ @count += 1
248
+ end
249
+
250
+ def decrement
251
+ @count -= 1
252
+ end
253
+
254
+ def reset
255
+ @count = 0
256
+ end
257
+
258
+ def private_helper_method
259
+ # This won't be available as a reflex since it's not in reflex_methods
260
+ end
261
+ end
262
+ ```
263
+
236
264
  ## Custom reflex base class
237
265
  Reflexes typically inherit from a base ApplicationReflex. You can define the base class for a view_component_reflex by using the `reflex_base_class` accessor.
238
266
  The parent class must inherit ViewComponentReflex::Reflex, and will throw an error if it does not.
@@ -78,6 +78,10 @@ module ViewComponentReflex
78
78
  name.chomp("Component").underscore.dasherize.gsub("/", "--")
79
79
  end
80
80
 
81
+ def self.reflex_methods
82
+ public_instance_methods - ViewComponentReflex::Component.instance_methods - [:call, :"_call_#{name.underscore}"]
83
+ end
84
+
81
85
  def stimulus_reflex?
82
86
  helpers.controller.instance_variable_get(:@stimulus_reflex)
83
87
  end
@@ -39,7 +39,7 @@ module ViewComponentReflex
39
39
  # class.
40
40
  # This replaces the old method_missing implementation, and passes more strict validation of recent SR versions
41
41
  def build_reflex_instance
42
- reflex_methods = @component.public_instance_methods - ViewComponentReflex::Component.instance_methods - [:call, :"_call_#{@component.name.underscore}"]
42
+ reflex_methods = @component.reflex_methods
43
43
  component_allocate = @component.allocate
44
44
  Class.new(@component.reflex_base_class).tap do |klass|
45
45
  klass.instance_variable_set(:@__method_parameters, {})
@@ -1,3 +1,3 @@
1
1
  module ViewComponentReflex
2
- VERSION = '3.3.15'
2
+ VERSION = '3.3.16'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: view_component_reflex
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.15
4
+ version: 3.3.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua LeBlanc