svelte-on-rails 8.0.0 → 8.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b2251e235c9c3ef4744e197e276e77ada5f0530baaf3b17ecbf9fc09a130cf98
4
- data.tar.gz: b4359024b0fa5ce9ebf02b2384b1ae7931cbb4982670a2a3a000c8b2cdd20d42
3
+ metadata.gz: 9fd78748cd0a7f9c896123e31dbbccab10dc7d42bc394a14fbc66efa360a166d
4
+ data.tar.gz: ce14713af9654cdbeb0e2ddf5cb9e46174308d9018c668b97f1db47b083e0324
5
5
  SHA512:
6
- metadata.gz: ab0dd3ba7377a4e485840bdddca3425ecacec267d98a37c74224450d2acffd34265dbb6021eaa443ced8e92205b70b4bfac6bc6e42d060670868730d81b7d586
7
- data.tar.gz: c665f45bbe57aab35cec4601dff88160a6818ad4f7055b8163d26b470feec82c76f75c024779913fc96bfe67aa4f6cfce451f22f78165b051379adf3b6d9dcd3
6
+ metadata.gz: 033d0d7cb3a2147119668913978f8a8fdba37d0467b7e7c756afaf60609352ed6bb2aa3805c1640c81a78dedb325eda7e298410c3df4485ed6f0fc7d796fa33c
7
+ data.tar.gz: f1b1830ad7056f1dff09077ba6576c6d64db6a8f27bfbfb9cc2dad70f128d0078137b9fbb970179c6702c677f443316f69c2d4f7e32dec33cca7aa37d6a8c6f9
data/README.md CHANGED
@@ -52,7 +52,7 @@ If you have issues, please open one, and contributors are welcome!
52
52
 
53
53
  **PROPS ON RUBY <= 3**
54
54
 
55
- On ruby <3 Arguments can be misinterpreted, see [issue-10](https://gitlab.com/sedl/svelte-on-rails/-/issues/10)
55
+ On ruby <3 Arguments are misinterpreted, see [issue-10](https://gitlab.com/sedl/svelte-on-rails/-/issues/10)
56
56
 
57
57
 
58
58
  ## Installation
@@ -1,11 +1,8 @@
1
1
  # lib/svelte_on_rails/active_record_extensions.rb
2
2
  module SvelteOnRails
3
+
4
+
3
5
  module ActiveRecordExtensions
4
- # def self.included(base)
5
- # unless defined?(ActiveRecord::Base) && base.ancestors.include?(ActiveRecord::Base)
6
- # raise 'SvelteOnRails::ActiveRecordExtensions can only be included in ActiveRecord models'
7
- # end
8
- # end
9
6
 
10
7
  # Returns a hash of attributes, methods, and associations formatted for Svelte components
11
8
  def to_svelte(*attributes, **associations)
@@ -13,29 +10,38 @@ module SvelteOnRails
13
10
 
14
11
  cl = SvelteOnRails::Lib::SvelteAttributes
15
12
  r = cl.new.calculate_instance(self, attributes, associations)
16
- r.first.merge({self.class.to_s.underscore => r[1]})
13
+ r.first.merge({ self.class.to_s.underscore => r[1] })
17
14
 
18
15
  end
19
16
  end
20
17
 
21
18
  end
22
19
 
20
+
21
+
23
22
  module ActiveRecordClassExtensions
23
+
24
24
  def to_svelte(*attributes, **associations)
25
+
25
26
  @to_svelte ||= begin
26
27
  cl = SvelteOnRails::Lib::SvelteAttributes
27
- cl.new.calculate_class(self, attributes, associations)
28
+ cl.new.calculate_class(self, attributes, associations)
28
29
  end
29
30
  end
31
+
30
32
  end
31
33
 
34
+
35
+
32
36
  module ActiveRecordRelationExtensions
37
+
33
38
  def to_svelte(*attributes, **associations)
34
39
  @to_svelte ||= begin
35
40
  cl = SvelteOnRails::Lib::SvelteAttributes
36
41
  cl.new.calculate_relation(self, attributes, associations)
37
42
  end
38
43
  end
44
+
39
45
  end
40
46
 
41
47
  end
@@ -15,16 +15,17 @@ module SvelteOnRails
15
15
 
16
16
  initializer 'svelte_on_rails.active_record_extensions' do
17
17
  ActiveSupport.on_load(:active_record) do
18
- # Include instance-level extensions
18
+ # Include instance-level extensions for ActiveRecord instances (e.g., @article)
19
19
  include SvelteOnRails::ActiveRecordExtensions
20
- # Extend with class-level extensions
21
- extend SvelteOnRails::ActiveRecordClassExtensions
20
+
21
+ # Extend ActiveRecord::Base with class-level extensions (e.g., Article)
22
+ ActiveRecord::Base.extend SvelteOnRails::ActiveRecordClassExtensions
23
+
24
+ # This also extends ActiveRecord::Relation (e.g., @articles)
25
+ ActiveRecord::Relation.include SvelteOnRails::ActiveRecordRelationExtensions
26
+
22
27
  end
23
- end
24
28
 
25
- # Extend ActiveRecord::Relation
26
- ActiveSupport.on_load(:active_record_relation) do
27
- include SvelteOnRails::ActiveRecordRelationExtensions
28
29
  end
29
30
 
30
31
  rake_tasks do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: svelte-on-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.0.0
4
+ version: 8.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Sedlmair