active_record_compose 0.3.2 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/lib/active_record_compose/delegate_attribute.rb +7 -10
- data/lib/active_record_compose/inner_model.rb +1 -1
- data/lib/active_record_compose/inner_model_collection.rb +3 -3
- data/lib/active_record_compose/model.rb +2 -2
- data/lib/active_record_compose/transaction_support.rb +2 -2
- data/lib/active_record_compose/version.rb +1 -1
- data/sig/active_record_compose.rbs +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1f089bd84bf403659ef6e4835080c952a07d7fb393aa7820c8b030294956f525
|
4
|
+
data.tar.gz: 9c9d6137b7c1d4715e89bc4c0f7c9e9965fdd3b9a2c265517ccac8568c3365fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e6a6bc59528725186b32d4447de1b7883e831cbdbd0579bfd5dadc100290a385ecd8410da67d760bf8bccc8c5548f73401319cb18b2289d649ad06a70184d42d
|
7
|
+
data.tar.gz: 1b25e47a0c9a4c49d1b8141499357b7f32bd6d724e05958531e98d164db3d738c1cf19c1045df96eae4d441e1144af610a6472c2372f018c32021aff12d0fa3b
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [0.3.4] - 2024-09-01
|
4
|
+
|
5
|
+
- ci: removed sqlite3 version specifing for new AR.
|
6
|
+
- `delegate_attribute` options are now specific and do not accept `prefix`
|
7
|
+
|
8
|
+
## [0.3.3] - 2024-06-24
|
9
|
+
|
10
|
+
- use steep:ignore
|
11
|
+
|
3
12
|
## [0.3.2] - 2024-04-10
|
4
13
|
|
5
14
|
- support `ActiveRecord::Base#with_connection`
|
@@ -38,13 +38,13 @@ module ActiveRecordCompose
|
|
38
38
|
extend ActiveSupport::Concern
|
39
39
|
|
40
40
|
included do
|
41
|
-
|
41
|
+
class_attribute :delegated_attributes, instance_writer: false # steep:ignore
|
42
42
|
end
|
43
43
|
|
44
44
|
module ClassMethods
|
45
45
|
# Defines the reader and writer for the specified attribute.
|
46
46
|
#
|
47
|
-
def delegate_attribute(*attributes, to:,
|
47
|
+
def delegate_attribute(*attributes, to:, allow_nil: nil, private: nil)
|
48
48
|
delegates = attributes.flat_map do |attribute|
|
49
49
|
reader = attribute.to_s
|
50
50
|
writer = "#{attribute}="
|
@@ -52,12 +52,9 @@ module ActiveRecordCompose
|
|
52
52
|
[reader, writer]
|
53
53
|
end
|
54
54
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
delegated_attributes = (self.delegated_attributes ||= [])
|
59
|
-
attributes.each { delegated_attributes.push(_1.to_s) }
|
60
|
-
end
|
55
|
+
delegate(*delegates, to:, allow_nil:, private:) # steep:ignore
|
56
|
+
delegated_attributes = (self.delegated_attributes ||= []) # steep:ignore
|
57
|
+
attributes.each { delegated_attributes.push(_1.to_s) }
|
61
58
|
end
|
62
59
|
end
|
63
60
|
|
@@ -66,8 +63,8 @@ module ActiveRecordCompose
|
|
66
63
|
#
|
67
64
|
# @return [Hash] hash with the attribute name as key and the attribute value as value.
|
68
65
|
def attributes
|
69
|
-
attrs =
|
70
|
-
delegates =
|
66
|
+
attrs = defined?(super) ? super : {} # steep:ignore
|
67
|
+
delegates = delegated_attributes # steep:ignore
|
71
68
|
|
72
69
|
# @type var attrs: Hash[String, untyped]
|
73
70
|
# @type var delegates: Array[String]
|
@@ -76,7 +76,7 @@ module ActiveRecordCompose
|
|
76
76
|
# @return [Boolean]
|
77
77
|
def ==(other)
|
78
78
|
return false unless self.class == other.class
|
79
|
-
return false unless
|
79
|
+
return false unless __raw_model == other.__raw_model # steep:ignore
|
80
80
|
return false unless context == other.context
|
81
81
|
|
82
82
|
true
|
@@ -14,7 +14,7 @@ module ActiveRecordCompose
|
|
14
14
|
def each
|
15
15
|
return enum_for(:each) unless block_given?
|
16
16
|
|
17
|
-
|
17
|
+
models.each { yield _1.__raw_model } # steep:ignore
|
18
18
|
self
|
19
19
|
end
|
20
20
|
|
@@ -73,7 +73,7 @@ module ActiveRecordCompose
|
|
73
73
|
def __each_by_wrapped
|
74
74
|
return enum_for(:__each_by_wrapped) unless block_given?
|
75
75
|
|
76
|
-
|
76
|
+
models.each { yield _1 if _1.__raw_model } # steep:ignore
|
77
77
|
self
|
78
78
|
end
|
79
79
|
|
@@ -82,7 +82,7 @@ module ActiveRecordCompose
|
|
82
82
|
def models = @models ||= []
|
83
83
|
|
84
84
|
def wrap(model, context:)
|
85
|
-
if
|
85
|
+
if model.is_a?(ActiveRecordCompose::InnerModel) # steep:ignore
|
86
86
|
# @type var model: ActiveRecordCompose::InnerModel
|
87
87
|
model
|
88
88
|
else
|
@@ -20,7 +20,7 @@ module ActiveRecordCompose
|
|
20
20
|
validate :validate_models
|
21
21
|
|
22
22
|
def initialize(attributes = {})
|
23
|
-
|
23
|
+
super
|
24
24
|
end
|
25
25
|
|
26
26
|
# Save the models that exist in models.
|
@@ -150,7 +150,7 @@ module ActiveRecordCompose
|
|
150
150
|
|
151
151
|
def models = @__models ||= ActiveRecordCompose::InnerModelCollection.new
|
152
152
|
|
153
|
-
def wrapped_models =
|
153
|
+
def wrapped_models = models.__each_by_wrapped # steep:ignore
|
154
154
|
|
155
155
|
def validate_models = wrapped_models.select { _1.invalid? }.each { errors.merge!(_1) }
|
156
156
|
|
@@ -8,7 +8,7 @@ module ActiveRecordCompose
|
|
8
8
|
module ClassMethods
|
9
9
|
def lease_connection
|
10
10
|
if ar_class.respond_to?(:lease_connection)
|
11
|
-
|
11
|
+
ar_class.lease_connection # steep:ignore
|
12
12
|
else
|
13
13
|
ar_class.connection
|
14
14
|
end
|
@@ -16,7 +16,7 @@ module ActiveRecordCompose
|
|
16
16
|
|
17
17
|
def connection = ar_class.connection
|
18
18
|
|
19
|
-
def with_connection(&) =
|
19
|
+
def with_connection(&) = ar_class.with_connection(&) # steep:ignore
|
20
20
|
|
21
21
|
def composite_primary_key? = false
|
22
22
|
|
@@ -24,7 +24,7 @@ module ActiveRecordCompose
|
|
24
24
|
def attributes: -> Hash[String, untyped]
|
25
25
|
|
26
26
|
module ClassMethods
|
27
|
-
def delegate_attribute: (*untyped methods, to: untyped?,
|
27
|
+
def delegate_attribute: (*untyped methods, to: untyped?, ?allow_nil: untyped?, ?private: untyped?) -> untyped
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_record_compose
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- hamajyotan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-09-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -52,7 +52,7 @@ metadata:
|
|
52
52
|
homepage_uri: https://github.com/hamajyotan/active_record_compose
|
53
53
|
source_code_uri: https://github.com/hamajyotan/active_record_compose
|
54
54
|
changelog_uri: https://github.com/hamajyotan/active_record_compose/blob/main/CHANGELOG.md
|
55
|
-
documentation_uri: https://www.rubydoc.info/gems/active_record_compose/0.3.
|
55
|
+
documentation_uri: https://www.rubydoc.info/gems/active_record_compose/0.3.4
|
56
56
|
rubygems_mfa_required: 'true'
|
57
57
|
post_install_message:
|
58
58
|
rdoc_options: []
|
@@ -69,7 +69,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
69
69
|
- !ruby/object:Gem::Version
|
70
70
|
version: '0'
|
71
71
|
requirements: []
|
72
|
-
rubygems_version: 3.5.
|
72
|
+
rubygems_version: 3.5.11
|
73
73
|
signing_key:
|
74
74
|
specification_version: 4
|
75
75
|
summary: activemodel form object pattern
|