inertia_rails 1.7.0 → 1.7.1
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/CHANGELOG.md +4 -0
- data/lib/inertia_rails/lazy.rb +23 -21
- data/lib/inertia_rails/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f3300d5a0d8ba1a4a433151b232dc06a2fbbdc337f8c1948b6a1fd52dbc20b4d
|
4
|
+
data.tar.gz: 3a62632643c8761c00fe3b462f2710d094a9adb06df0d7942b516c669eec7515
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 29d82e990a312f2392f14b209c10d6cb198d1f335d0b0e33b2d6821d8bcbc51adeb6d489362fbf2f124bc0b3605d152eb8470221c061eaf6dcae5083f5e86a79
|
7
|
+
data.tar.gz: 44565a5b1b36086a7baf965671fd09d5b1e75f3ed393c7de459e5a3c4a7a2d17bd5f485f0f9b68261631cd47cd371439357cd1a852ed2d6a82aa71268c51aaf8
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
5
5
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
|
+
## [1.7.1] - 2020-11-24
|
8
|
+
|
9
|
+
* Fix the definition for InertiaRails::Lazy to avoid an uninitialized constant error when booting an application.
|
10
|
+
|
7
11
|
## [1.7.0] - 2020-11-24
|
8
12
|
|
9
13
|
* Add support for "lazy" props while rendering. These are props that never compute on the initial page load. The only render during a partial update that calls for them explicitly.
|
data/lib/inertia_rails/lazy.rb
CHANGED
@@ -1,26 +1,28 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
module InertiaRails
|
2
|
+
class Lazy
|
3
|
+
def initialize(value = nil, &block)
|
4
|
+
@value = value
|
5
|
+
@block = block
|
6
|
+
end
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
8
|
+
def call
|
9
|
+
to_proc.call
|
10
|
+
end
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
12
|
+
def to_proc
|
13
|
+
# This is called by controller.instance_exec, which changes self to the
|
14
|
+
# controller instance. That makes the instance variables unavailable to the
|
15
|
+
# proc via closure. Copying the instance variables to local variables before
|
16
|
+
# the proc is returned keeps them in scope for the returned proc.
|
17
|
+
value = @value
|
18
|
+
block = @block
|
19
|
+
if value.respond_to?(:call)
|
20
|
+
value
|
21
|
+
elsif value
|
22
|
+
Proc.new { value }
|
23
|
+
else
|
24
|
+
block
|
25
|
+
end
|
24
26
|
end
|
25
27
|
end
|
26
28
|
end
|