acts_as_has_many 0.1.3 → 0.1.4
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 +4 -4
- data/CHANGELOG.md +7 -1
- data/README.md +44 -4
- data/lib/acts_as_has_many/version.rb +1 -1
- metadata +24 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: afc94ec7746ca6ad877adc8ea9942643c6d7c04fc0653fd0ecfe4453955202ca
|
4
|
+
data.tar.gz: b67e54b03a0fedef679306bc6e0a56609ce119da645f8e3de709f57cd29be6bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e1542d91fdce83668a7ffd0ea3239bd153829adf409ac9381d6ac712cf52f8b3fbfdc551616a1cca39b66a96de64be9918883199d54491b0fde349c19f2e26b0
|
7
|
+
data.tar.gz: 61e7c75d48216eff75b252492df8386dee3f2ee1539cbf47db0f6d61253510e59a0a12f786ca112bdb623e9947df9675e588db747e746540147316585d78d28a
|
data/CHANGELOG.md
CHANGED
@@ -18,4 +18,10 @@
|
|
18
18
|
|
19
19
|
- fix lint issues with rubocop
|
20
20
|
|
21
|
-
- use map + compact instead of filter_map to support older versions of ruby
|
21
|
+
- use map + compact instead of filter_map to support older versions of ruby
|
22
|
+
|
23
|
+
## [0.1.4]
|
24
|
+
|
25
|
+
- Updated Readme
|
26
|
+
|
27
|
+
- coverall setup
|
data/README.md
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
# ActsAsHasMany
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
3
|
+
ActsAsHasMany mimics a has_many association within an array stored in your ActiveRecord models. It provides a flexible way to define and manage custom associations using array attributes, without relying solely on standard ActiveRecord associations. Additionally, it supports nested forms by mimicking accepts_nested_attributes_for.
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
@@ -16,7 +14,49 @@ If bundler is not being used to manage dependencies, install the gem by executin
|
|
16
14
|
|
17
15
|
## Usage
|
18
16
|
|
19
|
-
|
17
|
+
Use the acts_as_has_many method to define custom array associations within your model:
|
18
|
+
|
19
|
+
```
|
20
|
+
class MyModel < ActiveRecord::Base
|
21
|
+
acts_as_has_many :some_attribute
|
22
|
+
end
|
23
|
+
```
|
24
|
+
|
25
|
+
`some_attribute` is an attrubute with in your model, and is expected to return an Array. It could be of any type `jsonb`, `text`, etc.
|
26
|
+
|
27
|
+
The gem will look for a class with the same name as the attribute, eg. `RelatedObject`
|
28
|
+
|
29
|
+
### Custom Class and OpenStruct
|
30
|
+
|
31
|
+
You can also specify custom class names for your associations.
|
32
|
+
|
33
|
+
```
|
34
|
+
class MyModel < ActiveRecord::Base
|
35
|
+
acts_as_has_many :some_attribute, class_name: 'OtherClass'
|
36
|
+
end
|
37
|
+
```
|
38
|
+
|
39
|
+
If you prefer not to create a new class, you can use OpenStruct.
|
40
|
+
|
41
|
+
```
|
42
|
+
class MyModel < ActiveRecord::Base
|
43
|
+
acts_as_has_many :some_attribute, class_name: 'OpenStruct'
|
44
|
+
end
|
45
|
+
```
|
46
|
+
|
47
|
+
### Custom Attribute
|
48
|
+
|
49
|
+
By default, ActsAsHasMany overrides the attribute getter and setter methods. If you prefer to use different attribute, you can specify a custom attribute using the :attribute option:
|
50
|
+
|
51
|
+
```
|
52
|
+
class MyModel < ActiveRecord::Base
|
53
|
+
acts_as_has_many :some_attribute, attribute: :some_other_attribute
|
54
|
+
end
|
55
|
+
```
|
56
|
+
|
57
|
+
## Support and Contact
|
58
|
+
|
59
|
+
If you have any questions, issues, or feedback, please open an issue on the GitHub repository.
|
20
60
|
|
21
61
|
## Development
|
22
62
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts_as_has_many
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pralish Kayastha
|
@@ -25,21 +25,21 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '6.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
@@ -53,7 +53,7 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: sqlite3
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
@@ -67,49 +67,49 @@ dependencies:
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: rspec
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '3'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - "
|
80
|
+
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
82
|
+
version: '3'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: appraisal
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - "
|
87
|
+
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
89
|
+
version: '2.1'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - "
|
94
|
+
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
96
|
+
version: '2.1'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
98
|
+
name: coveralls_reborn
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- - "
|
101
|
+
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
103
|
+
version: '0'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- - "
|
108
|
+
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
110
|
+
version: '0'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
112
|
+
name: simplecov-lcov
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
115
|
- - ">="
|