alba-inertia 0.1.2 → 0.1.3

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: 36892b105c78f91a4874dca3d397e42be762acf30fcd56f379e1f2672683def0
4
- data.tar.gz: 8dfc87dca73d0594fcc7233e48bdf73d2cc62f6f082bfe0e820685cfa827603c
3
+ metadata.gz: f8c5c1926cf157ea4d3cfc5b1c93a0a4899186c034926871ee506f109677a5d7
4
+ data.tar.gz: 1fee181488d0ca6d5852d2c8fe1f7b57df023e85648a98ba9b42e46d023ee71b
5
5
  SHA512:
6
- metadata.gz: 74b25910459121487726f3a3d1be5c235dacd494cc25d9bc0dfb337e0900e962be3c5283e8a2667476cf1dcff1314a984781c04ab037f7eddcf2b09379296b48
7
- data.tar.gz: d36a4bde371ad4322c595f251ce7a83c4cd0e83e6459695603044d8987e6d029b6556783337135a668ac76410cec19a57634492e805c252c86744d6d95efeddd
6
+ metadata.gz: 4a705b90d9050542fbfc152a915ad808685dbeb450bba8001672be0545f4c1b1986c08c9e97098d9454556ceb000f09cc92bdb848b3bb3d6ecf8f4fa7c98cf99
7
+ data.tar.gz: '098535869f8f87c9ef4eb4655589ee6813324ec925b8c4bd5387fe8349e453ca05b486f6bad1ecb97440ab3e943322e0dce33ee61d24d8119e25cd4021929381'
data/CHANGELOG.md CHANGED
@@ -7,11 +7,17 @@ and this project adheres to [Semantic Versioning].
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.1.3] - 2025-12-08
11
+
12
+ ### Added
13
+
14
+ - Support for `InertiaRails.once`. ([@skryukov])
15
+
10
16
  ## [0.1.2] - 2025-12-08
11
17
 
12
18
  ### Added
13
19
 
14
- - Support for `InertiaRails.scroll` attributes. ([@skryukov])
20
+ - Support for `InertiaRails.scroll`. ([@skryukov])
15
21
  - Add `serializer_params` option to `render_inertia` and `inertia_serializer_params` controller method for passing params to serializers. ([@skryukov])
16
22
 
17
23
  ## [0.1.1] - 2025-11-05
@@ -33,7 +39,8 @@ and this project adheres to [Semantic Versioning].
33
39
 
34
40
  [@skryukov]: https://github.com/skryukov
35
41
 
36
- [Unreleased]: https://github.com/skryukov/alba-inertia/compare/v0.1.2...HEAD
42
+ [Unreleased]: https://github.com/skryukov/alba-inertia/compare/v0.1.3...HEAD
43
+ [0.1.3]: https://github.com/skryukov/alba-inertia/compare/v0.1.2...v0.1.3
37
44
  [0.1.2]: https://github.com/skryukov/alba-inertia/compare/v0.1.1...v0.1.2
38
45
  [0.1.1]: https://github.com/skryukov/alba-inertia/compare/v0.1.0...v0.1.1
39
46
  [0.1.0]: https://github.com/skryukov/alba-inertia/commits/v0.1.0
data/README.md CHANGED
@@ -71,8 +71,12 @@ class CoursesIndexResource < ApplicationResource
71
71
 
72
72
  # Scroll prop with explicit metadata
73
73
  has_many :items, inertia: { scroll: :meta }
74
- has_many :items, inertia: { scroll: -> { |obj| obj.meta } }
75
- has_many :items, inertia: { scroll: -> { |obj| obj.meta }, wrapper: 'data' }
74
+ has_many :items, inertia: { scroll: ->(obj) { obj.meta } }
75
+ has_many :items, inertia: { scroll: ->(obj) { obj.meta }, wrapper: 'data' }
76
+
77
+ # Once prop
78
+ has_many :plans, inertia: :once
79
+ has_many :plans, inertia: { once: { key: 'active_plans', expires_in: 1.hour, fresh: ->(obj) { obj.fresh? } } }
76
80
  end
77
81
  ```
78
82
 
@@ -3,10 +3,14 @@
3
3
  module Alba
4
4
  module Inertia
5
5
  class PropBuilder
6
+ ONCE_KEYS = %i[once key expires_in fresh]
7
+
6
8
  class << self
7
9
  def build(evaluation_block, options, object = nil)
8
10
  if options[:optional]
9
11
  wrap_optional(evaluation_block, options[:optional], object)
12
+ elsif options[:once]
13
+ wrap_once(evaluation_block, options[:once], object)
10
14
  elsif options[:defer]
11
15
  wrap_defer(evaluation_block, options[:defer], object)
12
16
  elsif options[:merge]
@@ -26,18 +30,27 @@ module Alba
26
30
  ::InertiaRails.always(&value_block)
27
31
  end
28
32
 
29
- def wrap_optional(value_block, _opts, _object)
30
- ::InertiaRails.optional(&value_block)
33
+ def wrap_optional(value_block, opts, _object)
34
+ if opts.is_a?(Hash)
35
+ options = opts.slice(*ONCE_KEYS)
36
+ ::InertiaRails.optional(**options, &value_block)
37
+ else
38
+ ::InertiaRails.optional(&value_block)
39
+ end
40
+ end
41
+
42
+ def wrap_once(value_block, opts, _object)
43
+ if opts.is_a?(Hash)
44
+ options = opts.slice(*ONCE_KEYS)
45
+ ::InertiaRails.once(**options, &value_block)
46
+ else
47
+ ::InertiaRails.once(&value_block)
48
+ end
31
49
  end
32
50
 
33
51
  def wrap_defer(value_block, opts, _object)
34
52
  if opts.is_a?(Hash)
35
- options = {
36
- group: opts[:group],
37
- merge: opts[:merge],
38
- deep_merge: opts[:deep_merge],
39
- match_on: opts[:match_on]
40
- }.compact
53
+ options = opts.slice(:group, :deep_merge, :merge, :match_on, *ONCE_KEYS)
41
54
 
42
55
  ::InertiaRails.defer(**options, &value_block)
43
56
  else
@@ -47,7 +60,7 @@ module Alba
47
60
 
48
61
  def wrap_merge(value_block, opts, _object)
49
62
  if opts.is_a?(Hash)
50
- options = {match_on: opts[:match_on]}.compact
63
+ options = opts.slice(:match_on, *ONCE_KEYS)
51
64
  ::InertiaRails.merge(**options, &value_block)
52
65
  else
53
66
  ::InertiaRails.merge(&value_block)
@@ -59,6 +59,7 @@ module Alba
59
59
  def inertia_prop(name, **kwargs)
60
60
  options = {
61
61
  optional: kwargs.delete(:optional) || false,
62
+ once: kwargs.delete(:once) || false,
62
63
  defer: kwargs.delete(:defer) || false,
63
64
  merge: kwargs.delete(:merge) || false,
64
65
  scroll: kwargs.delete(:scroll) || false,
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Alba
4
4
  module Inertia
5
- VERSION = "0.1.2"
5
+ VERSION = "0.1.3"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alba-inertia
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Svyatoslav Kryukov
@@ -91,7 +91,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
91
91
  - !ruby/object:Gem::Version
92
92
  version: '0'
93
93
  requirements: []
94
- rubygems_version: 4.0.0
94
+ rubygems_version: 3.6.9
95
95
  specification_version: 4
96
96
  summary: Seamless integration between Alba and Inertia Rails.
97
97
  test_files: []