active_typed_store 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.idea/.gitignore +8 -0
- data/.idea/active_typed_store.iml +60 -0
- data/.idea/misc.xml +4 -0
- data/.idea/modules.xml +8 -0
- data/.idea/vcs.xml +6 -0
- data/.rspec +3 -0
- data/.rubocop.yml +18 -0
- data/Gemfile +13 -0
- data/Gemfile.lock +135 -0
- data/LICENSE.txt +21 -0
- data/README.md +39 -0
- data/Rakefile +12 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/lib/active_typed_store/store.rb +59 -0
- data/lib/active_typed_store/version.rb +7 -0
- data/lib/active_typed_store.rb +9 -0
- metadata +105 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ea8f72cf52df59724509616f3310915ab16412feab8a557a87c79539b2b80ca2
|
4
|
+
data.tar.gz: d2a3952dd7d3b9f33eb739252ed825df10b0b963e7d75b7eb3250ea681647bd9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 46e9e4f714695b77993821285db5f15c221f74bea815a63441e9a8ae51617d40dc6470b9bd6e54fd2d2e451dfaaf30863feea7fb075e259bf9f145e22c7ef814
|
7
|
+
data.tar.gz: ae243ba632aca1bb0a05502ec32a81c6f0f44e218b2feb6acb008c00819c7fb17ed4a37402e1c5dec7bcf93a41227b86f9a9acad4fbf1385fca85455e90c4452
|
data/.idea/.gitignore
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<module type="RUBY_MODULE" version="4">
|
3
|
+
<component name="ModuleRunConfigurationManager">
|
4
|
+
<shared />
|
5
|
+
</component>
|
6
|
+
<component name="NewModuleRootManager">
|
7
|
+
<content url="file://$MODULE_DIR$">
|
8
|
+
<sourceFolder url="file://$MODULE_DIR$/features" isTestSource="true" />
|
9
|
+
<sourceFolder url="file://$MODULE_DIR$/spec" isTestSource="true" />
|
10
|
+
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
|
11
|
+
</content>
|
12
|
+
<orderEntry type="inheritedJdk" />
|
13
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
14
|
+
<orderEntry type="library" scope="PROVIDED" name="activemodel (v6.0.4.4, rbenv: 2.7.4) [gem]" level="application" />
|
15
|
+
<orderEntry type="library" scope="PROVIDED" name="activerecord (v6.0.4.4, rbenv: 2.7.4) [gem]" level="application" />
|
16
|
+
<orderEntry type="library" scope="PROVIDED" name="activesupport (v6.0.4.4, rbenv: 2.7.4) [gem]" level="application" />
|
17
|
+
<orderEntry type="library" scope="PROVIDED" name="ast (v2.4.2, rbenv: 2.7.4) [gem]" level="application" />
|
18
|
+
<orderEntry type="library" scope="PROVIDED" name="bundler (v2.2.29, rbenv: 2.7.4) [gem]" level="application" />
|
19
|
+
<orderEntry type="library" scope="PROVIDED" name="coderay (v1.1.3, rbenv: 2.7.4) [gem]" level="application" />
|
20
|
+
<orderEntry type="library" scope="PROVIDED" name="colorize (v0.8.1, rbenv: 2.7.4) [gem]" level="application" />
|
21
|
+
<orderEntry type="library" scope="PROVIDED" name="concurrent-ruby (v1.1.9, rbenv: 2.7.4) [gem]" level="application" />
|
22
|
+
<orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.4.4, rbenv: 2.7.4) [gem]" level="application" />
|
23
|
+
<orderEntry type="library" scope="PROVIDED" name="dry-configurable (v0.13.0, rbenv: 2.7.4) [gem]" level="application" />
|
24
|
+
<orderEntry type="library" scope="PROVIDED" name="dry-container (v0.9.0, rbenv: 2.7.4) [gem]" level="application" />
|
25
|
+
<orderEntry type="library" scope="PROVIDED" name="dry-core (v0.7.1, rbenv: 2.7.4) [gem]" level="application" />
|
26
|
+
<orderEntry type="library" scope="PROVIDED" name="dry-inflector (v0.2.1, rbenv: 2.7.4) [gem]" level="application" />
|
27
|
+
<orderEntry type="library" scope="PROVIDED" name="dry-logic (v1.2.0, rbenv: 2.7.4) [gem]" level="application" />
|
28
|
+
<orderEntry type="library" scope="PROVIDED" name="dry-types (v1.5.1, rbenv: 2.7.4) [gem]" level="application" />
|
29
|
+
<orderEntry type="library" scope="PROVIDED" name="i18n (v1.8.11, rbenv: 2.7.4) [gem]" level="application" />
|
30
|
+
<orderEntry type="library" scope="PROVIDED" name="method_source (v1.0.0, rbenv: 2.7.4) [gem]" level="application" />
|
31
|
+
<orderEntry type="library" scope="PROVIDED" name="minitest (v5.15.0, rbenv: 2.7.4) [gem]" level="application" />
|
32
|
+
<orderEntry type="library" scope="PROVIDED" name="parallel (v1.21.0, rbenv: 2.7.4) [gem]" level="application" />
|
33
|
+
<orderEntry type="library" scope="PROVIDED" name="parser (v3.0.3.2, rbenv: 2.7.4) [gem]" level="application" />
|
34
|
+
<orderEntry type="library" scope="PROVIDED" name="priscilla (v1.0.3@46ba74, rbenv: 2.7.4) [gem]" level="application" />
|
35
|
+
<orderEntry type="library" scope="PROVIDED" name="pry (v0.14.1, rbenv: 2.7.4) [gem]" level="application" />
|
36
|
+
<orderEntry type="library" scope="PROVIDED" name="rack (v2.2.3, rbenv: 2.7.4) [gem]" level="application" />
|
37
|
+
<orderEntry type="library" scope="PROVIDED" name="rainbow (v3.0.0, rbenv: 2.7.4) [gem]" level="application" />
|
38
|
+
<orderEntry type="library" scope="PROVIDED" name="rake (v13.0.6, rbenv: 2.7.4) [gem]" level="application" />
|
39
|
+
<orderEntry type="library" scope="PROVIDED" name="regexp_parser (v2.2.0, rbenv: 2.7.4) [gem]" level="application" />
|
40
|
+
<orderEntry type="library" scope="PROVIDED" name="rexml (v3.2.5, rbenv: 2.7.4) [gem]" level="application" />
|
41
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec (v3.9.0, rbenv: 2.7.4) [gem]" level="application" />
|
42
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec-core (v3.9.3, rbenv: 2.7.4) [gem]" level="application" />
|
43
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v3.9.4, rbenv: 2.7.4) [gem]" level="application" />
|
44
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v3.9.1, rbenv: 2.7.4) [gem]" level="application" />
|
45
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec-support (v3.9.4, rbenv: 2.7.4) [gem]" level="application" />
|
46
|
+
<orderEntry type="library" scope="PROVIDED" name="rubocop (v1.23.0, rbenv: 2.7.4) [gem]" level="application" />
|
47
|
+
<orderEntry type="library" scope="PROVIDED" name="rubocop-ast (v1.15.0, rbenv: 2.7.4) [gem]" level="application" />
|
48
|
+
<orderEntry type="library" scope="PROVIDED" name="rubocop-gp (v0.0.2@4d390b, rbenv: 2.7.4) [gem]" level="application" />
|
49
|
+
<orderEntry type="library" scope="PROVIDED" name="rubocop-performance (v1.12.0, rbenv: 2.7.4) [gem]" level="application" />
|
50
|
+
<orderEntry type="library" scope="PROVIDED" name="rubocop-rails (v2.12.4, rbenv: 2.7.4) [gem]" level="application" />
|
51
|
+
<orderEntry type="library" scope="PROVIDED" name="rubocop-rspec (v2.6.0, rbenv: 2.7.4) [gem]" level="application" />
|
52
|
+
<orderEntry type="library" scope="PROVIDED" name="ruby-progressbar (v1.11.0, rbenv: 2.7.4) [gem]" level="application" />
|
53
|
+
<orderEntry type="library" scope="PROVIDED" name="rumoji (v0.5.0, rbenv: 2.7.4) [gem]" level="application" />
|
54
|
+
<orderEntry type="library" scope="PROVIDED" name="sqlite3 (v1.4.2, rbenv: 2.7.4) [gem]" level="application" />
|
55
|
+
<orderEntry type="library" scope="PROVIDED" name="thread_safe (v0.3.6, rbenv: 2.7.4) [gem]" level="application" />
|
56
|
+
<orderEntry type="library" scope="PROVIDED" name="tzinfo (v1.2.9, rbenv: 2.7.4) [gem]" level="application" />
|
57
|
+
<orderEntry type="library" scope="PROVIDED" name="unicode-display_width (v2.1.0, rbenv: 2.7.4) [gem]" level="application" />
|
58
|
+
<orderEntry type="library" scope="PROVIDED" name="zeitwerk (v2.5.1, rbenv: 2.7.4) [gem]" level="application" />
|
59
|
+
</component>
|
60
|
+
</module>
|
data/.idea/misc.xml
ADDED
data/.idea/modules.xml
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<project version="4">
|
3
|
+
<component name="ProjectModuleManager">
|
4
|
+
<modules>
|
5
|
+
<module fileurl="file://$PROJECT_DIR$/.idea/active_typed_store.iml" filepath="$PROJECT_DIR$/.idea/active_typed_store.iml" />
|
6
|
+
</modules>
|
7
|
+
</component>
|
8
|
+
</project>
|
data/.idea/vcs.xml
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
inherit_gem:
|
2
|
+
rubocop-gp:
|
3
|
+
- .rubocop.yml
|
4
|
+
|
5
|
+
AllCops:
|
6
|
+
TargetRubyVersion: 2.6
|
7
|
+
|
8
|
+
Lint/ConstantDefinitionInBlock:
|
9
|
+
Enabled: false
|
10
|
+
|
11
|
+
RSpec/LeakyConstantDeclaration:
|
12
|
+
Enabled: false
|
13
|
+
|
14
|
+
Rails/ApplicationRecord:
|
15
|
+
Enabled: false
|
16
|
+
|
17
|
+
Rails/TimeZone:
|
18
|
+
Enabled: false
|
data/Gemfile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source 'https://rubygems.org'
|
4
|
+
|
5
|
+
gemspec
|
6
|
+
|
7
|
+
gem 'dry-types'
|
8
|
+
gem 'priscilla', github: 'corp-gp/priscilla'
|
9
|
+
gem 'pry', '~> 0.12'
|
10
|
+
gem 'rake', '~> 13.0'
|
11
|
+
gem 'rspec', '~> 3.9'
|
12
|
+
gem 'rubocop-gp', github: 'corp-gp/rubocop-gp'
|
13
|
+
gem 'sqlite3', '~> 1.4'
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,135 @@
|
|
1
|
+
GIT
|
2
|
+
remote: https://github.com/corp-gp/priscilla.git
|
3
|
+
revision: 46ba7460df8209dfe80e344beed07dfe56648aaf
|
4
|
+
specs:
|
5
|
+
priscilla (1.0.3)
|
6
|
+
colorize (~> 0.7)
|
7
|
+
rumoji (~> 0.3)
|
8
|
+
|
9
|
+
GIT
|
10
|
+
remote: https://github.com/corp-gp/rubocop-gp.git
|
11
|
+
revision: 4d390b6cdd2b27f151fe0535bd266525fbf8f25d
|
12
|
+
specs:
|
13
|
+
rubocop-gp (0.0.2)
|
14
|
+
rubocop
|
15
|
+
rubocop-performance
|
16
|
+
rubocop-rails
|
17
|
+
rubocop-rspec
|
18
|
+
|
19
|
+
PATH
|
20
|
+
remote: .
|
21
|
+
specs:
|
22
|
+
active_typed_store (0.1.0)
|
23
|
+
activemodel (~> 6.0)
|
24
|
+
activerecord (~> 6.0)
|
25
|
+
activesupport (~> 6.0)
|
26
|
+
|
27
|
+
GEM
|
28
|
+
remote: https://rubygems.org/
|
29
|
+
specs:
|
30
|
+
activemodel (6.0.4.4)
|
31
|
+
activesupport (= 6.0.4.4)
|
32
|
+
activerecord (6.0.4.4)
|
33
|
+
activemodel (= 6.0.4.4)
|
34
|
+
activesupport (= 6.0.4.4)
|
35
|
+
activesupport (6.0.4.4)
|
36
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
37
|
+
i18n (>= 0.7, < 2)
|
38
|
+
minitest (~> 5.1)
|
39
|
+
tzinfo (~> 1.1)
|
40
|
+
zeitwerk (~> 2.2, >= 2.2.2)
|
41
|
+
ast (2.4.2)
|
42
|
+
coderay (1.1.3)
|
43
|
+
colorize (0.8.1)
|
44
|
+
concurrent-ruby (1.1.9)
|
45
|
+
diff-lcs (1.4.4)
|
46
|
+
dry-configurable (0.13.0)
|
47
|
+
concurrent-ruby (~> 1.0)
|
48
|
+
dry-core (~> 0.6)
|
49
|
+
dry-container (0.9.0)
|
50
|
+
concurrent-ruby (~> 1.0)
|
51
|
+
dry-configurable (~> 0.13, >= 0.13.0)
|
52
|
+
dry-core (0.7.1)
|
53
|
+
concurrent-ruby (~> 1.0)
|
54
|
+
dry-inflector (0.2.1)
|
55
|
+
dry-logic (1.2.0)
|
56
|
+
concurrent-ruby (~> 1.0)
|
57
|
+
dry-core (~> 0.5, >= 0.5)
|
58
|
+
dry-types (1.5.1)
|
59
|
+
concurrent-ruby (~> 1.0)
|
60
|
+
dry-container (~> 0.3)
|
61
|
+
dry-core (~> 0.5, >= 0.5)
|
62
|
+
dry-inflector (~> 0.1, >= 0.1.2)
|
63
|
+
dry-logic (~> 1.0, >= 1.0.2)
|
64
|
+
i18n (1.8.11)
|
65
|
+
concurrent-ruby (~> 1.0)
|
66
|
+
method_source (1.0.0)
|
67
|
+
minitest (5.15.0)
|
68
|
+
parallel (1.21.0)
|
69
|
+
parser (3.0.3.2)
|
70
|
+
ast (~> 2.4.1)
|
71
|
+
pry (0.14.1)
|
72
|
+
coderay (~> 1.1)
|
73
|
+
method_source (~> 1.0)
|
74
|
+
rack (2.2.3)
|
75
|
+
rainbow (3.0.0)
|
76
|
+
rake (13.0.6)
|
77
|
+
regexp_parser (2.2.0)
|
78
|
+
rexml (3.2.5)
|
79
|
+
rspec (3.9.0)
|
80
|
+
rspec-core (~> 3.9.0)
|
81
|
+
rspec-expectations (~> 3.9.0)
|
82
|
+
rspec-mocks (~> 3.9.0)
|
83
|
+
rspec-core (3.9.3)
|
84
|
+
rspec-support (~> 3.9.3)
|
85
|
+
rspec-expectations (3.9.4)
|
86
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
87
|
+
rspec-support (~> 3.9.0)
|
88
|
+
rspec-mocks (3.9.1)
|
89
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
90
|
+
rspec-support (~> 3.9.0)
|
91
|
+
rspec-support (3.9.4)
|
92
|
+
rubocop (1.23.0)
|
93
|
+
parallel (~> 1.10)
|
94
|
+
parser (>= 3.0.0.0)
|
95
|
+
rainbow (>= 2.2.2, < 4.0)
|
96
|
+
regexp_parser (>= 1.8, < 3.0)
|
97
|
+
rexml
|
98
|
+
rubocop-ast (>= 1.12.0, < 2.0)
|
99
|
+
ruby-progressbar (~> 1.7)
|
100
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
101
|
+
rubocop-ast (1.15.0)
|
102
|
+
parser (>= 3.0.1.1)
|
103
|
+
rubocop-performance (1.12.0)
|
104
|
+
rubocop (>= 1.7.0, < 2.0)
|
105
|
+
rubocop-ast (>= 0.4.0)
|
106
|
+
rubocop-rails (2.12.4)
|
107
|
+
activesupport (>= 4.2.0)
|
108
|
+
rack (>= 1.1)
|
109
|
+
rubocop (>= 1.7.0, < 2.0)
|
110
|
+
rubocop-rspec (2.6.0)
|
111
|
+
rubocop (~> 1.19)
|
112
|
+
ruby-progressbar (1.11.0)
|
113
|
+
rumoji (0.5.0)
|
114
|
+
sqlite3 (1.4.2)
|
115
|
+
thread_safe (0.3.6)
|
116
|
+
tzinfo (1.2.9)
|
117
|
+
thread_safe (~> 0.1)
|
118
|
+
unicode-display_width (2.1.0)
|
119
|
+
zeitwerk (2.5.1)
|
120
|
+
|
121
|
+
PLATFORMS
|
122
|
+
x86_64-linux
|
123
|
+
|
124
|
+
DEPENDENCIES
|
125
|
+
active_typed_store!
|
126
|
+
dry-types
|
127
|
+
priscilla!
|
128
|
+
pry (~> 0.12)
|
129
|
+
rake (~> 13.0)
|
130
|
+
rspec (~> 3.9)
|
131
|
+
rubocop-gp!
|
132
|
+
sqlite3 (~> 1.4)
|
133
|
+
|
134
|
+
BUNDLED WITH
|
135
|
+
2.2.29
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2021 Ermolaev Andrey
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# ActiveTypedStore
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/active_typed_store`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'active_typed_store'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle install
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install active_typed_store
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/active_typed_store.
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
require "active_typed_store"
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require "irb"
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ActiveTypedStore
|
4
|
+
module Store
|
5
|
+
|
6
|
+
JSON_NOT_SERIALIZED_TYPES = [
|
7
|
+
ActiveModel::Type::Date,
|
8
|
+
ActiveModel::Type::DateTime,
|
9
|
+
ActiveModel::Type::Time,
|
10
|
+
].freeze
|
11
|
+
|
12
|
+
def typed_store(store_attribute, attrs)
|
13
|
+
store_accessor store_attribute, attrs.keys
|
14
|
+
|
15
|
+
attrs.each do |key, value_klass|
|
16
|
+
key = key.to_s
|
17
|
+
define_method("#{key}?") do
|
18
|
+
read_store_attribute(store_attribute, key).present?
|
19
|
+
end
|
20
|
+
|
21
|
+
_setter_for_typed_store(store_attribute, key, value_klass)
|
22
|
+
_getter_for_typed_store(key, value_klass)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def _setter_for_typed_store(store_attribute, key, value_klass)
|
27
|
+
if value_klass.name.start_with?('ActiveModel::Type::')
|
28
|
+
define_method("#{key}=") do |value|
|
29
|
+
v = value_klass.new.cast(value)
|
30
|
+
write_store_attribute(store_attribute, key, v)
|
31
|
+
self[store_attribute].delete(key) if v.nil?
|
32
|
+
end
|
33
|
+
else
|
34
|
+
define_method("#{key}=") do |value|
|
35
|
+
v = value.nil? ? nil : value_klass[value]
|
36
|
+
write_store_attribute(store_attribute, key, v)
|
37
|
+
self[store_attribute].delete(key) if v.nil?
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def _getter_for_typed_store(key, value_klass)
|
43
|
+
if JSON_NOT_SERIALIZED_TYPES.include?(value_klass)
|
44
|
+
define_method(key) do
|
45
|
+
val = super()
|
46
|
+
value_klass.new.cast(val) unless val.nil?
|
47
|
+
end
|
48
|
+
elsif value_klass.is_a?(Dry::Types::Default)
|
49
|
+
define_method(key) do
|
50
|
+
val = super()
|
51
|
+
# value_klass.value возвращает default
|
52
|
+
# value_klass[nil] для optional типов возвращает не default-значение, а nil
|
53
|
+
val.nil? ? value_klass.value : val
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
end
|
metadata
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: active_typed_store
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ermolaev Andrey
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-12-21 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activemodel
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '6.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '6.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: activerecord
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '6.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '6.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: activesupport
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '6.0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '6.0'
|
55
|
+
description:
|
56
|
+
email:
|
57
|
+
- andruhafirst@yandex.ru
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".idea/.gitignore"
|
63
|
+
- ".idea/active_typed_store.iml"
|
64
|
+
- ".idea/misc.xml"
|
65
|
+
- ".idea/modules.xml"
|
66
|
+
- ".idea/vcs.xml"
|
67
|
+
- ".rspec"
|
68
|
+
- ".rubocop.yml"
|
69
|
+
- Gemfile
|
70
|
+
- Gemfile.lock
|
71
|
+
- LICENSE.txt
|
72
|
+
- README.md
|
73
|
+
- Rakefile
|
74
|
+
- bin/console
|
75
|
+
- bin/setup
|
76
|
+
- lib/active_typed_store.rb
|
77
|
+
- lib/active_typed_store/store.rb
|
78
|
+
- lib/active_typed_store/version.rb
|
79
|
+
homepage: https://github.com/corp-gp/active_typed_store
|
80
|
+
licenses:
|
81
|
+
- MIT
|
82
|
+
metadata:
|
83
|
+
allowed_push_host: https://rubygems.org
|
84
|
+
homepage_uri: https://github.com/corp-gp/active_typed_store
|
85
|
+
source_code_uri: https://github.com/corp-gp/active_typed_store
|
86
|
+
post_install_message:
|
87
|
+
rdoc_options: []
|
88
|
+
require_paths:
|
89
|
+
- lib
|
90
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: 2.6.0
|
95
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
requirements: []
|
101
|
+
rubygems_version: 3.1.6
|
102
|
+
signing_key:
|
103
|
+
specification_version: 4
|
104
|
+
summary: Typed store for active records json/hstore columns
|
105
|
+
test_files: []
|