inertia_rails 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +15 -0
- data/lib/inertia_rails/inertia_rails.rb +4 -4
- data/lib/inertia_rails/renderer.rb +4 -3
- data/lib/inertia_rails/version.rb +1 -1
- data/lib/inertia_rails.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5a987e189bffe559a7fd30a5a4af407dd992126196af7f57fe7d496205faefae
|
4
|
+
data.tar.gz: dd688cdcb38097978329cacb91db8b76d18db98dd3dc44bf9bddd03e784d6f5d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2aeccf87d9e621b7617ec111f04bcb2032c4c574793a73f59895985bb73d94546f073c3a091b9ba1d66bd46eac5536e626bbae3892a6e9789fcef5952c20b63f
|
7
|
+
data.tar.gz: 8cba5c80ecde60604dc9d93dd1269448bd6fd99411852b0b4f58f20b9e792aa63a0afd9867bdf35ad984d6ca4205734b1f587e206b15dee3e0370587b4ab911e
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# Changelog
|
2
|
+
All notable changes to this project will be documented in this file.
|
3
|
+
|
4
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
5
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
|
+
|
7
|
+
## [1.0.1] - 2019-10-23
|
8
|
+
|
9
|
+
### Fixed
|
10
|
+
|
11
|
+
* Allow `Intertia.share` within a controller to access controller methods
|
12
|
+
|
13
|
+
## [1.0.0] - 2019-10-09
|
14
|
+
|
15
|
+
* Initial release
|
@@ -7,8 +7,8 @@ module InertiaRails
|
|
7
7
|
end
|
8
8
|
|
9
9
|
# "Getters"
|
10
|
-
def self.shared_data
|
11
|
-
shared_plain_data.merge!(evaluated_blocks(shared_blocks))
|
10
|
+
def self.shared_data(controller)
|
11
|
+
shared_plain_data.merge!(evaluated_blocks(controller, shared_blocks))
|
12
12
|
end
|
13
13
|
|
14
14
|
def self.version
|
@@ -39,7 +39,7 @@ module InertiaRails
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
-
def self.evaluated_blocks(blocks)
|
43
|
-
blocks.flat_map(
|
42
|
+
def self.evaluated_blocks(controller, blocks)
|
43
|
+
blocks.flat_map { |block| controller.instance_exec(&block) }.reduce(&:merge) || {}
|
44
44
|
end
|
45
45
|
end
|
@@ -4,8 +4,9 @@ module InertiaRails
|
|
4
4
|
class Renderer
|
5
5
|
attr_reader :component, :view_data
|
6
6
|
|
7
|
-
def initialize(component, request, response, render_method, props:, view_data:)
|
7
|
+
def initialize(component, controller, request, response, render_method, props:, view_data:)
|
8
8
|
@component = component
|
9
|
+
@controller = controller
|
9
10
|
@request = request
|
10
11
|
@response = response
|
11
12
|
@render_method = render_method
|
@@ -28,13 +29,13 @@ module InertiaRails
|
|
28
29
|
def props
|
29
30
|
only = (@request.headers['X-Inertia-Partial-Data'] || '').split(',').compact.map(&:to_sym)
|
30
31
|
|
31
|
-
_props = ::InertiaRails.shared_data.merge(@props)
|
32
|
+
_props = ::InertiaRails.shared_data(@controller).merge(@props)
|
32
33
|
|
33
34
|
_props = (only.any? && @request.headers['X-Inertia-Partial-Component'] == component) ?
|
34
35
|
_props.select {|key| key.in? only} :
|
35
36
|
_props
|
36
37
|
|
37
|
-
deep_transform_values(_props, lambda {|prop| prop.respond_to?(:call) ? prop
|
38
|
+
deep_transform_values(_props, lambda {|prop| prop.respond_to?(:call) ? @controller.instance_exec(&prop) : prop })
|
38
39
|
end
|
39
40
|
|
40
41
|
def page
|
data/lib/inertia_rails.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: inertia_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Knoles
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2019-10-
|
13
|
+
date: 2019-10-23 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|
@@ -66,6 +66,7 @@ files:
|
|
66
66
|
- ".gitignore"
|
67
67
|
- ".rspec"
|
68
68
|
- ".travis.yml"
|
69
|
+
- CHANGELOG.md
|
69
70
|
- CODE_OF_CONDUCT.md
|
70
71
|
- Gemfile
|
71
72
|
- LICENSE.txt
|