stimulus_reflex_globalid 0.1.2 → 0.2.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 +4 -4
- data/README.md +11 -0
- data/lib/stimulus_reflex_globalid/engine.rb +18 -3
- data/lib/stimulus_reflex_globalid/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dd88a9b7294e63992aa8bdb41e10e6f826e97ae52d22e75cae13c0e81eb16a8e
|
4
|
+
data.tar.gz: dd36e583e959ecc490adc8304737716bfc7bf3dacc3433eb25a6c2c61ceba82b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ecd8f0a88abab31b368cc2c4f48171b7c19d1cd7cc2eb2c34f00c2a456321c38ccfccacbe326e8f117c3904cfc9b35dab6a23921542a6e222450f760bd77a79f
|
7
|
+
data.tar.gz: ef72769f8eb3ce52a13e4c680807f0b3892beaf3274a46248dc7a09cd5e3ef7fb92c85783397b095dd17429c0b757df60557428054f62c2d4bc50da97a13bc83
|
data/README.md
CHANGED
@@ -27,5 +27,16 @@ end
|
|
27
27
|
|
28
28
|
You can also use signed IDs.
|
29
29
|
|
30
|
+
## Configuring
|
31
|
+
|
32
|
+
You can turn off signed/unsigned IDs by configuring the gem.
|
33
|
+
|
34
|
+
```
|
35
|
+
StimulusReflexGlobalid::Engine.configure do |config|
|
36
|
+
config.allow_signed = false # default true
|
37
|
+
config.allow_unsigned = false # default true
|
38
|
+
end
|
39
|
+
```
|
40
|
+
|
30
41
|
## License
|
31
42
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
@@ -2,6 +2,14 @@ module StimulusReflexGlobalid
|
|
2
2
|
class Engine < ::Rails::Engine
|
3
3
|
isolate_namespace StimulusReflexGlobalid
|
4
4
|
|
5
|
+
class << self
|
6
|
+
mattr_accessor :allow_signed
|
7
|
+
mattr_accessor :allow_unsigned
|
8
|
+
|
9
|
+
self.allow_signed = true
|
10
|
+
self.allow_signed = true
|
11
|
+
end
|
12
|
+
|
5
13
|
@monkey_patched = false
|
6
14
|
config.to_prepare do
|
7
15
|
StimulusReflex::Reflex.class_eval do
|
@@ -15,13 +23,20 @@ module StimulusReflexGlobalid
|
|
15
23
|
original_initialize(channel, url: url, element: element, selectors: selectors, method_name: method_name, permanent_attribute_name: permanent_attribute_name, params: params)
|
16
24
|
|
17
25
|
@element.dataset.to_h.each do |k, v|
|
18
|
-
|
19
|
-
|
20
|
-
|
26
|
+
model = nil
|
27
|
+
|
28
|
+
model = GlobalID::Locator.locate(v) if StimulusReflexGlobalid::Engine.allow_unsigned
|
29
|
+
model = GlobalID::Locator.locate_signed(v) if StimulusReflexGlobalid::Engine.allow_signed && !model
|
30
|
+
|
31
|
+
instance_variable_set(:"@#{k}", model) if model
|
21
32
|
end
|
22
33
|
end
|
23
34
|
end
|
24
35
|
end
|
25
36
|
end
|
37
|
+
|
38
|
+
def self.configure
|
39
|
+
yield self if block_given?
|
40
|
+
end
|
26
41
|
end
|
27
42
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stimulus_reflex_globalid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.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-10-
|
11
|
+
date: 2020-10-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|