active_record_compose 0.1.1 → 0.1.2
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e22d1fa89d36de73833897c0bead3b9b0405fe357aad4565d873741648a3664e
|
4
|
+
data.tar.gz: d9c543c3c0048428d22a0f591bd6086c6da991a9768d6836f84b212126ff9cab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 85dcb6f44d523a9cd85905dca4bfb5557594b123872d61015fab442e4a92957bd05835f43f2113fbb44b5771e3f4c4b8856a4bbb97d3a6ef39f4a35803a5457b
|
7
|
+
data.tar.gz: 31f30d80ebbf8ab7f752330f25e5cc8777f2e4801a3648c71c5e36e1d6717e46530540b555c7efe96cb0e2f144d93206d7f181b6aedcfab79a140b1e37ce86cd
|
data/.rubocop.yml
CHANGED
@@ -3,6 +3,9 @@ AllCops:
|
|
3
3
|
NewCops: enable
|
4
4
|
SuggestExtensions: false
|
5
5
|
|
6
|
+
Gemspec/DevelopmentDependencies:
|
7
|
+
Enabled: false
|
8
|
+
|
6
9
|
Style/Documentation:
|
7
10
|
Enabled: false
|
8
11
|
|
@@ -29,3 +32,6 @@ Layout/LineLength:
|
|
29
32
|
|
30
33
|
Metrics/BlockLength:
|
31
34
|
Enabled: false
|
35
|
+
|
36
|
+
Naming/MemoizedInstanceVariableName:
|
37
|
+
Enabled: false
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [0.1.2] - 2024-01-09
|
4
|
+
|
5
|
+
- fix and add doc.
|
6
|
+
- add development dependency
|
7
|
+
- avoid instance variable name conflict (`@models` to `@__models`)
|
8
|
+
- add #empty?, #clear to InnerModelCollection
|
9
|
+
- add #delete to InnerModelCollection
|
10
|
+
|
3
11
|
## [0.1.1] - 2024-01-08
|
4
12
|
|
5
13
|
- fix 0.1.0 release date.
|
@@ -42,6 +42,17 @@ module ActiveRecordCompose
|
|
42
42
|
# @return [Boolean]
|
43
43
|
def valid? = !invalid?
|
44
44
|
|
45
|
+
# Returns true if equivalent.
|
46
|
+
#
|
47
|
+
# @return [Object] other
|
48
|
+
def ==(other)
|
49
|
+
return false unless self.class == other.class
|
50
|
+
return false unless __raw_model == other.__raw_model
|
51
|
+
return false unless context == other.context
|
52
|
+
|
53
|
+
true
|
54
|
+
end
|
55
|
+
|
45
56
|
# Returns a model instance of raw, but it should
|
46
57
|
# be noted that application developers are not expected to use this interface.
|
47
58
|
#
|
@@ -21,7 +21,6 @@ module ActiveRecordCompose
|
|
21
21
|
# Appends model to collection.
|
22
22
|
#
|
23
23
|
# @param model [Object] the model instance
|
24
|
-
# @param context [Symbol] :save or :destroy
|
25
24
|
# @return [InnerModelCollection] self
|
26
25
|
def <<(model)
|
27
26
|
models << wrap(model, context: :save)
|
@@ -31,12 +30,40 @@ module ActiveRecordCompose
|
|
31
30
|
# Appends model to collection.
|
32
31
|
#
|
33
32
|
# @param model [Object] the model instance
|
33
|
+
# @param context [Symbol] :save or :destroy
|
34
34
|
# @return [InnerModelCollection] self
|
35
35
|
def push(model, context: :save)
|
36
36
|
models << wrap(model, context:)
|
37
37
|
self
|
38
38
|
end
|
39
39
|
|
40
|
+
# Returns true if the element exists.
|
41
|
+
#
|
42
|
+
# @return [Boolean] Returns true if the element exists
|
43
|
+
def empty? = models.empty?
|
44
|
+
|
45
|
+
# Set to empty.
|
46
|
+
#
|
47
|
+
# @return [InnerModelCollection] self
|
48
|
+
def clear
|
49
|
+
models.clear
|
50
|
+
self
|
51
|
+
end
|
52
|
+
|
53
|
+
# Removes the specified model from the collection.
|
54
|
+
# Returns nil if the deletion fails, self if it succeeds.
|
55
|
+
#
|
56
|
+
# @param model [Object] the model instance
|
57
|
+
# @param context [Symbol] :save or :destroy
|
58
|
+
# @return [InnerModelCollection] Successful deletion
|
59
|
+
# @return [nil] If deletion fails
|
60
|
+
def delete(model, context: :save)
|
61
|
+
wrapped = wrap(model, context:)
|
62
|
+
return nil unless models.delete(wrapped)
|
63
|
+
|
64
|
+
self
|
65
|
+
end
|
66
|
+
|
40
67
|
# Enumerates model objects, but it should be noted that
|
41
68
|
# application developers are not expected to use this interface.
|
42
69
|
#
|
@@ -110,7 +110,7 @@ module ActiveRecordCompose
|
|
110
110
|
|
111
111
|
private
|
112
112
|
|
113
|
-
def models = @
|
113
|
+
def models = @__models ||= ActiveRecordCompose::InnerModelCollection.new
|
114
114
|
|
115
115
|
def wrapped_models = models.__each_by_wrapped
|
116
116
|
|
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.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- hamajyotan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-01-
|
11
|
+
date: 2024-01-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '6.1'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
description: activemodel form object pattern
|
28
42
|
email:
|
29
43
|
- hamajyotan@gmail.com
|
@@ -49,8 +63,10 @@ homepage: https://github.com/active_record_compose
|
|
49
63
|
licenses:
|
50
64
|
- MIT
|
51
65
|
metadata:
|
52
|
-
|
53
|
-
source_code_uri: https://github.com/
|
66
|
+
homepage_uri: https://github.com/active_record_compose
|
67
|
+
source_code_uri: https://github.com/active_record_compose
|
68
|
+
changelog_uri: https://github.com/active_record_compose/blob/main/CHANGELOG.md
|
69
|
+
documentation_uri: https://www.rubydoc.info/gems/active_record_compose/0.1.2
|
54
70
|
rubygems_mfa_required: 'true'
|
55
71
|
post_install_message:
|
56
72
|
rdoc_options: []
|