activerecord-typedstore 1.4.0 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +12 -29
- data/README.md +6 -3
- data/activerecord-typedstore.gemspec +1 -4
- data/gemfiles/Gemfile.ar-6.1 +0 -1
- data/gemfiles/{Gemfile.ar-5.2 → Gemfile.ar-7.0} +1 -1
- data/gemfiles/Gemfile.ar-master +0 -1
- data/lib/active_record/typed_store/dsl.rb +41 -5
- data/lib/active_record/typed_store/extension.rb +8 -7
- data/lib/active_record/typed_store/version.rb +1 -1
- data/spec/active_record/typed_store_spec.rb +76 -0
- data/spec/spec_helper.rb +0 -9
- data/spec/support/models.rb +22 -77
- metadata +6 -50
- data/gemfiles/Gemfile.ar-5.0 +0 -6
- data/gemfiles/Gemfile.ar-6.0 +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e4f681cbd23a432d2e40094499e45a693ebacc8784d639dbd35f5d7467d3f024
|
4
|
+
data.tar.gz: 2adde8a50a784c41a23e188d51ababc7c19a553d6e4599e2265dad9c70ea5ebe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 67570832d5d8f6d7d05617f2f6572ed1e629bb1463f4bc123513d84219306a2aca59439082eed57a00d80e97474bd1b5a63269a94caabd530769bd8c098c3da6
|
7
|
+
data.tar.gz: a9f3f3d3ab6bbbe4b47625674fde96e3f3c8c0fbb697f2b557b1aa089ed45bd91e2c3bff98c0bbee8c55d52bc3d473bf16fc92759b65ad5a84548d91a5e81b14
|
data/.github/workflows/ruby.yml
CHANGED
@@ -7,16 +7,10 @@ jobs:
|
|
7
7
|
runs-on: ubuntu-latest
|
8
8
|
name: Ruby ${{ matrix.ruby }}
|
9
9
|
strategy:
|
10
|
+
fail-fast: false
|
10
11
|
matrix:
|
11
|
-
ruby: [2.
|
12
|
-
gemfile: [Gemfile.ar-
|
13
|
-
exclude:
|
14
|
-
- ruby: 2.6
|
15
|
-
gemfile: Gemfile.ar-6.0
|
16
|
-
- ruby: 2.6
|
17
|
-
gemfile: Gemfile.ar-6.1
|
18
|
-
- ruby: 2.6
|
19
|
-
gemfile: Gemfile.ar-master
|
12
|
+
ruby: ['2.7', '3.0', '3.1']
|
13
|
+
gemfile: [Gemfile.ar-6.1, Gemfile.ar-7.0, Gemfile.ar-master]
|
20
14
|
timezone_aware: [0, 1]
|
21
15
|
env:
|
22
16
|
BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}
|
@@ -25,23 +19,12 @@ jobs:
|
|
25
19
|
MYSQL: 1
|
26
20
|
POSTGRES_JSON: 1
|
27
21
|
steps:
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
sudo systemctl start mysql.service
|
38
|
-
mysql -uroot -proot -e 'create database typed_store_test;'
|
39
|
-
- name: Start PostgresQL and create DB
|
40
|
-
run: |
|
41
|
-
sudo sed -i s/md5/trust/g /etc/postgresql/*/main/pg_hba.conf
|
42
|
-
sudo systemctl start postgresql.service
|
43
|
-
sudo -u postgres createuser --createdb --superuser ${USER}
|
44
|
-
createdb typed_store_test
|
45
|
-
echo "POSTGRES_URL=postgres://localhost/typed_store_test" >> $GITHUB_ENV
|
46
|
-
- name: Ruby Tests
|
47
|
-
run: bundle exec rake
|
22
|
+
- name: Check out code
|
23
|
+
uses: actions/checkout@v2
|
24
|
+
- name: Set up Ruby ${{ matrix.ruby }}
|
25
|
+
uses: ruby/setup-ruby@v1
|
26
|
+
with:
|
27
|
+
ruby-version: ${{ matrix.ruby }}
|
28
|
+
bundler-cache: true
|
29
|
+
- name: Ruby Tests
|
30
|
+
run: bundle exec rake
|
data/README.md
CHANGED
@@ -1,8 +1,5 @@
|
|
1
1
|
# ActiveRecord::TypedStore
|
2
2
|
|
3
|
-
[![Build Status](https://secure.travis-ci.org/byroot/activerecord-typedstore.png)](http://travis-ci.org/byroot/activerecord-typedstore)
|
4
|
-
[![Code Climate](https://codeclimate.com/github/byroot/activerecord-typedstore.png)](https://codeclimate.com/github/byroot/activerecord-typedstore)
|
5
|
-
[![Coverage Status](https://coveralls.io/repos/byroot/activerecord-typedstore/badge.png)](https://coveralls.io/r/byroot/activerecord-typedstore)
|
6
3
|
[![Gem Version](https://badge.fury.io/rb/activerecord-typedstore.png)](http://badge.fury.io/rb/activerecord-typedstore)
|
7
4
|
|
8
5
|
[ActiveRecord::Store](http://api.rubyonrails.org/classes/ActiveRecord/Store.html) but with typed attributes.
|
@@ -79,6 +76,12 @@ shop.save
|
|
79
76
|
shop.reload
|
80
77
|
shop.settings[:unknown] # => 'Hello World'
|
81
78
|
|
79
|
+
# You can group attributes with a prefix or suffix
|
80
|
+
typed_store(:browser, prefix: true) { |s| s.string :ip } # => #browser_ip
|
81
|
+
typed_store(:browser, prefix: :web) { |s| s.string :ip } # => #web_ip
|
82
|
+
typed_store(:browser, suffix: true) { |s| s.string :ip } # => #ip_browser
|
83
|
+
typed_store(:browser, suffix: :web) { |s| s.string :ip } # => #ip_web
|
84
|
+
|
82
85
|
# If you only want type casting and default handling without accessors
|
83
86
|
|
84
87
|
# you can disable them store wide
|
@@ -18,14 +18,11 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ['lib']
|
20
20
|
|
21
|
-
spec.add_dependency 'activerecord', '>=
|
21
|
+
spec.add_dependency 'activerecord', '>= 6.1'
|
22
22
|
|
23
23
|
spec.add_development_dependency 'bundler'
|
24
24
|
spec.add_development_dependency 'rake', '~> 10'
|
25
25
|
spec.add_development_dependency 'rspec', '~> 3'
|
26
|
-
spec.add_development_dependency 'coveralls', '~> 0'
|
27
26
|
spec.add_development_dependency 'sqlite3', '~> 1'
|
28
|
-
spec.add_development_dependency 'pg', ENV.fetch('PG_VERSION', '~> 0.18')
|
29
|
-
spec.add_development_dependency 'mysql2', '> 0.3'
|
30
27
|
spec.add_development_dependency 'database_cleaner', '~> 1'
|
31
28
|
end
|
data/gemfiles/Gemfile.ar-6.1
CHANGED
data/gemfiles/Gemfile.ar-master
CHANGED
@@ -6,10 +6,38 @@ module ActiveRecord::TypedStore
|
|
6
6
|
class DSL
|
7
7
|
attr_reader :fields, :coder
|
8
8
|
|
9
|
-
def initialize(
|
10
|
-
@coder = options.fetch(:coder) { default_coder(
|
11
|
-
@
|
12
|
-
@
|
9
|
+
def initialize(store_name, options)
|
10
|
+
@coder = options.fetch(:coder) { default_coder(store_name) }
|
11
|
+
@store_name = store_name
|
12
|
+
@prefix =
|
13
|
+
case options[:prefix]
|
14
|
+
when String, Symbol
|
15
|
+
"#{options[:prefix]}_"
|
16
|
+
when true
|
17
|
+
"#{store_name}_"
|
18
|
+
when false, nil
|
19
|
+
""
|
20
|
+
else
|
21
|
+
raise ArgumentError, "Unexpected type for prefix option. Expected string, symbol, or boolean"
|
22
|
+
end
|
23
|
+
@suffix =
|
24
|
+
case options[:suffix]
|
25
|
+
when String, Symbol
|
26
|
+
"_#{options[:suffix]}"
|
27
|
+
when true
|
28
|
+
"_#{store_name}"
|
29
|
+
when false, nil
|
30
|
+
""
|
31
|
+
else
|
32
|
+
raise ArgumentError, "Unexpected type for suffix option. Expected string, symbol, or boolean"
|
33
|
+
end
|
34
|
+
@accessors = if options[:accessors] == false
|
35
|
+
{}
|
36
|
+
elsif options[:accessors].is_a?(Array)
|
37
|
+
options[:accessors].each_with_object({}) do |accessor_name, hash|
|
38
|
+
hash[accessor_name] = accessor_key_for(accessor_name)
|
39
|
+
end
|
40
|
+
end
|
13
41
|
@fields = {}
|
14
42
|
yield self
|
15
43
|
end
|
@@ -25,7 +53,9 @@ module ActiveRecord::TypedStore
|
|
25
53
|
end
|
26
54
|
|
27
55
|
def accessors
|
28
|
-
@accessors || @fields.values.select(&:accessor).
|
56
|
+
@accessors || @fields.values.select(&:accessor).each_with_object({}) do |field, hash|
|
57
|
+
hash[field.name] = accessor_key_for(field.name)
|
58
|
+
end
|
29
59
|
end
|
30
60
|
|
31
61
|
delegate :keys, to: :@fields
|
@@ -37,5 +67,11 @@ module ActiveRecord::TypedStore
|
|
37
67
|
end
|
38
68
|
end
|
39
69
|
alias_method :date_time, :datetime
|
70
|
+
|
71
|
+
private
|
72
|
+
|
73
|
+
def accessor_key_for(name)
|
74
|
+
"#{@prefix}#{name}#{@suffix}"
|
75
|
+
end
|
40
76
|
end
|
41
77
|
end
|
@@ -14,9 +14,10 @@ module ActiveRecord::TypedStore
|
|
14
14
|
class_attribute :typed_stores, :store_accessors, instance_accessor: false
|
15
15
|
end
|
16
16
|
|
17
|
+
store_options = options.slice(:prefix, :suffix)
|
17
18
|
dsl = DSL.new(store_attribute, options, &block)
|
18
19
|
self.typed_stores = (self.typed_stores || {}).merge(store_attribute => dsl)
|
19
|
-
self.store_accessors = typed_stores.each_value.flat_map
|
20
|
+
self.store_accessors = typed_stores.each_value.flat_map { |d| d.accessors.values }.map { |a| -a.to_s }.to_set
|
20
21
|
|
21
22
|
typed_klass = TypedHash.create(dsl.fields.values)
|
22
23
|
const_set("#{store_attribute}_hash".camelize, typed_klass)
|
@@ -31,20 +32,20 @@ module ActiveRecord::TypedStore
|
|
31
32
|
Type.new(typed_klass, dsl.coder, subtype)
|
32
33
|
end
|
33
34
|
end
|
34
|
-
store_accessor(store_attribute, dsl.accessors)
|
35
|
+
store_accessor(store_attribute, dsl.accessors.keys, **store_options)
|
35
36
|
|
36
|
-
dsl.accessors.each do |accessor_name|
|
37
|
-
define_method("#{
|
37
|
+
dsl.accessors.each do |accessor_name, accessor_key|
|
38
|
+
define_method("#{accessor_key}_changed?") do
|
38
39
|
send("#{store_attribute}_changed?") &&
|
39
40
|
send(store_attribute)[accessor_name] != send("#{store_attribute}_was")[accessor_name]
|
40
41
|
end
|
41
42
|
|
42
|
-
define_method("#{
|
43
|
+
define_method("#{accessor_key}_was") do
|
43
44
|
send("#{store_attribute}_was")[accessor_name]
|
44
45
|
end
|
45
46
|
|
46
|
-
define_method("restore_#{
|
47
|
-
send("#{
|
47
|
+
define_method("restore_#{accessor_key}!") do
|
48
|
+
send("#{accessor_key}=", send("#{accessor_name}_was"))
|
48
49
|
end
|
49
50
|
end
|
50
51
|
end
|
@@ -696,6 +696,82 @@ shared_examples 'a store' do |retain_type = true, settings_type = :text|
|
|
696
696
|
|
697
697
|
end
|
698
698
|
|
699
|
+
describe 'with prefix true' do
|
700
|
+
|
701
|
+
it 'defines prefixed accessors' do
|
702
|
+
expect(model).to respond_to :prefixed_settings_language
|
703
|
+
expect(model).to respond_to :prefixed_settings_language=
|
704
|
+
end
|
705
|
+
|
706
|
+
it 'does not define unprefixed accessors' do
|
707
|
+
expect(model).not_to respond_to :language
|
708
|
+
expect(model).not_to respond_to :language=
|
709
|
+
end
|
710
|
+
|
711
|
+
it 'can be updated' do
|
712
|
+
model.update(prefixed_settings_language: 'en')
|
713
|
+
expect(model.reload.prefixed_settings_language).to be == 'en'
|
714
|
+
end
|
715
|
+
|
716
|
+
end
|
717
|
+
|
718
|
+
describe 'with custom prefix' do
|
719
|
+
|
720
|
+
it 'defines prefixed accessors' do
|
721
|
+
expect(model).to respond_to :custom_language
|
722
|
+
expect(model).to respond_to :custom_language=
|
723
|
+
end
|
724
|
+
|
725
|
+
it 'does not define unprefixed accessors' do
|
726
|
+
expect(model).not_to respond_to :language
|
727
|
+
expect(model).not_to respond_to :language=
|
728
|
+
end
|
729
|
+
|
730
|
+
it 'can be updated' do
|
731
|
+
model.update(custom_language: 'en')
|
732
|
+
expect(model.reload.custom_language).to be == 'en'
|
733
|
+
end
|
734
|
+
|
735
|
+
end
|
736
|
+
|
737
|
+
describe 'with suffix true' do
|
738
|
+
|
739
|
+
it 'defines suffixed accessors' do
|
740
|
+
expect(model).to respond_to :language_suffixed_settings
|
741
|
+
expect(model).to respond_to :language_suffixed_settings=
|
742
|
+
end
|
743
|
+
|
744
|
+
it 'does not define unprefixed accessors' do
|
745
|
+
expect(model).not_to respond_to :language
|
746
|
+
expect(model).not_to respond_to :language=
|
747
|
+
end
|
748
|
+
|
749
|
+
it 'can be updated' do
|
750
|
+
model.update(language_suffixed_settings: 'en')
|
751
|
+
expect(model.reload.language_suffixed_settings).to be == 'en'
|
752
|
+
end
|
753
|
+
|
754
|
+
end
|
755
|
+
|
756
|
+
describe 'with custom suffix' do
|
757
|
+
|
758
|
+
it 'defines suffixed accessors' do
|
759
|
+
expect(model).to respond_to :language_custom
|
760
|
+
expect(model).to respond_to :language_custom=
|
761
|
+
end
|
762
|
+
|
763
|
+
it 'does not define unprefixed accessors' do
|
764
|
+
expect(model).not_to respond_to :language
|
765
|
+
expect(model).not_to respond_to :language=
|
766
|
+
end
|
767
|
+
|
768
|
+
it 'can be updated' do
|
769
|
+
model.update(language_custom: 'en')
|
770
|
+
expect(model.reload.language_custom).to be == 'en'
|
771
|
+
end
|
772
|
+
|
773
|
+
end
|
774
|
+
|
699
775
|
describe '`any` attributes' do
|
700
776
|
|
701
777
|
it 'accept any type' do
|
data/spec/spec_helper.rb
CHANGED
@@ -2,15 +2,6 @@ lib = File.expand_path('../lib', __FILE__)
|
|
2
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
3
|
|
4
4
|
require 'database_cleaner'
|
5
|
-
|
6
|
-
require 'simplecov'
|
7
|
-
require 'coveralls'
|
8
|
-
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
|
9
|
-
SimpleCov::Formatter::HTMLFormatter,
|
10
|
-
Coveralls::SimpleCov::Formatter
|
11
|
-
])
|
12
|
-
SimpleCov.start
|
13
|
-
|
14
5
|
require 'activerecord-typedstore'
|
15
6
|
|
16
7
|
Dir[File.expand_path(File.join(File.dirname(__FILE__), 'support', '**', '*.rb'))].each { |f| require f }
|
data/spec/support/models.rb
CHANGED
@@ -2,11 +2,14 @@ require 'active_record'
|
|
2
2
|
require 'json'
|
3
3
|
require 'yaml'
|
4
4
|
|
5
|
+
ENV["RAILS_ENV"] = "test"
|
6
|
+
|
5
7
|
ActiveRecord::Base.time_zone_aware_attributes = ENV['TIMEZONE_AWARE'] != '0'
|
8
|
+
credentials = { 'database' => 'typed_store_test', 'username' => 'typed_store', 'password' => 'typed_store' }
|
6
9
|
ActiveRecord::Base.configurations = {
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
+
test: {
|
11
|
+
'test_sqlite3' => { 'adapter' => 'sqlite3', 'database' => '/tmp/typed_store.db' },
|
12
|
+
}
|
10
13
|
}
|
11
14
|
|
12
15
|
def define_columns(t)
|
@@ -39,12 +42,7 @@ def define_columns(t)
|
|
39
42
|
|
40
43
|
t.integer :grades, array: true
|
41
44
|
|
42
|
-
|
43
|
-
# native sqlite cannot automatically cast array to yaml
|
44
|
-
t.string :tags, array: true, null: false, default: [].to_yaml
|
45
|
-
else
|
46
|
-
t.string :tags, array: true, null: false, default: []
|
47
|
-
end
|
45
|
+
t.string :tags, array: true, null: false, default: [].to_yaml
|
48
46
|
|
49
47
|
t.string :nickname, blank: false, default: 'Please enter your nickname'
|
50
48
|
end
|
@@ -74,37 +72,22 @@ def define_store_with_attributes(**options)
|
|
74
72
|
end
|
75
73
|
end
|
76
74
|
|
75
|
+
def define_stores_with_prefix_and_suffix(**options)
|
76
|
+
typed_store(:prefixed_settings, prefix: true, **options) { |t| t.any :language }
|
77
|
+
typed_store(:suffixed_settings, suffix: true, **options) { |t| t.any :language }
|
78
|
+
typed_store(:custom_prefixed_settings, prefix: :custom, **options) { |t| t.any :language }
|
79
|
+
typed_store(:custom_suffixed_settings, suffix: :custom, **options) { |t| t.any :language }
|
80
|
+
end
|
81
|
+
|
77
82
|
MigrationClass = ActiveRecord::Migration["5.0"]
|
78
83
|
class CreateAllTables < MigrationClass
|
79
84
|
|
80
|
-
def self.recreate_table(name, *args, &block)
|
81
|
-
execute "drop table if exists #{name}"
|
82
|
-
create_table(name, *args, &block)
|
83
|
-
end
|
84
|
-
|
85
85
|
def self.up
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
if ENV['POSTGRES']
|
92
|
-
ActiveRecord::Base.establish_connection(ENV['POSTGRES_URL'] || :test_postgresql)
|
93
|
-
recreate_table(:postgresql_regular_ar_models) { |t| define_columns(t); t.text :untyped_settings }
|
94
|
-
|
95
|
-
execute "create extension if not exists hstore"
|
96
|
-
recreate_table(:postgres_hstore_typed_store_models) { |t| t.hstore :settings; t.text :untyped_settings }
|
97
|
-
|
98
|
-
if ENV['POSTGRES_JSON']
|
99
|
-
recreate_table(:postgres_json_typed_store_models) { |t| t.json :settings; t.text :explicit_settings; t.text :partial_settings; t.text :untyped_settings }
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
ActiveRecord::Base.establish_connection(:test_sqlite3)
|
104
|
-
recreate_table(:sqlite3_regular_ar_models) { |t| define_columns(t); t.text :untyped_settings }
|
105
|
-
recreate_table(:yaml_typed_store_models) { |t| t.text :settings; t.text :explicit_settings; t.text :partial_settings; t.text :untyped_settings }
|
106
|
-
recreate_table(:json_typed_store_models) { |t| t.text :settings; t.text :explicit_settings; t.text :partial_settings; t.text :untyped_settings }
|
107
|
-
recreate_table(:marshal_typed_store_models) { |t| t.text :settings; t.text :explicit_settings; t.text :partial_settings; t.text :untyped_settings }
|
86
|
+
ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations.configs_for(env_name: "test", name: :test_sqlite3))
|
87
|
+
create_table(:sqlite3_regular_ar_models, force: true) { |t| define_columns(t); t.text :untyped_settings }
|
88
|
+
create_table(:yaml_typed_store_models, force: true) { |t| %i[settings explicit_settings partial_settings untyped_settings prefixed_settings suffixed_settings custom_prefixed_settings custom_suffixed_settings].each { |column| t.text column} }
|
89
|
+
create_table(:json_typed_store_models, force: true) { |t| %i[settings explicit_settings partial_settings untyped_settings prefixed_settings suffixed_settings custom_prefixed_settings custom_suffixed_settings].each { |column| t.text column} }
|
90
|
+
create_table(:marshal_typed_store_models, force: true) { |t| %i[settings explicit_settings partial_settings untyped_settings prefixed_settings suffixed_settings custom_prefixed_settings custom_suffixed_settings].each { |column| t.text column} }
|
108
91
|
end
|
109
92
|
end
|
110
93
|
ActiveRecord::Migration.verbose = true
|
@@ -129,44 +112,6 @@ class ColumnCoder
|
|
129
112
|
|
130
113
|
end
|
131
114
|
|
132
|
-
module AsJson
|
133
|
-
extend self
|
134
|
-
|
135
|
-
def load(value)
|
136
|
-
value
|
137
|
-
end
|
138
|
-
|
139
|
-
def dump(value)
|
140
|
-
value.as_json
|
141
|
-
end
|
142
|
-
|
143
|
-
end
|
144
|
-
|
145
|
-
if ENV['MYSQL']
|
146
|
-
class MysqlRegularARModel < ActiveRecord::Base
|
147
|
-
establish_connection :test_mysql
|
148
|
-
store :untyped_settings, accessors: [:title]
|
149
|
-
end
|
150
|
-
end
|
151
|
-
|
152
|
-
if ENV['POSTGRES']
|
153
|
-
class PostgresqlRegularARModel < ActiveRecord::Base
|
154
|
-
establish_connection ENV['POSTGRES_URL'] || :test_postgresql
|
155
|
-
store :untyped_settings, accessors: [:title]
|
156
|
-
end
|
157
|
-
|
158
|
-
if ENV['POSTGRES_JSON']
|
159
|
-
class PostgresJsonTypedStoreModel < ActiveRecord::Base
|
160
|
-
establish_connection ENV['POSTGRES_URL'] || :test_postgresql
|
161
|
-
store :untyped_settings, accessors: [:title]
|
162
|
-
|
163
|
-
define_store_with_attributes(coder: ColumnCoder.new(AsJson))
|
164
|
-
define_store_with_no_attributes(coder: ColumnCoder.new(AsJson))
|
165
|
-
define_store_with_partial_attributes(coder: ColumnCoder.new(AsJson))
|
166
|
-
end
|
167
|
-
end
|
168
|
-
end
|
169
|
-
|
170
115
|
class Sqlite3RegularARModel < ActiveRecord::Base
|
171
116
|
establish_connection :test_sqlite3
|
172
117
|
store :untyped_settings, accessors: [:title]
|
@@ -179,6 +124,7 @@ class YamlTypedStoreModel < ActiveRecord::Base
|
|
179
124
|
define_store_with_attributes
|
180
125
|
define_store_with_no_attributes
|
181
126
|
define_store_with_partial_attributes
|
127
|
+
define_stores_with_prefix_and_suffix
|
182
128
|
end
|
183
129
|
|
184
130
|
class InheritedTypedStoreModel < YamlTypedStoreModel
|
@@ -196,6 +142,7 @@ class JsonTypedStoreModel < ActiveRecord::Base
|
|
196
142
|
define_store_with_attributes(coder: ColumnCoder.new(JSON))
|
197
143
|
define_store_with_no_attributes(coder: ColumnCoder.new(JSON))
|
198
144
|
define_store_with_partial_attributes(coder: ColumnCoder.new(JSON))
|
145
|
+
define_stores_with_prefix_and_suffix(coder: ColumnCoder.new(JSON))
|
199
146
|
end
|
200
147
|
|
201
148
|
module MarshalCoder
|
@@ -218,6 +165,7 @@ class MarshalTypedStoreModel < ActiveRecord::Base
|
|
218
165
|
define_store_with_attributes(coder: ColumnCoder.new(MarshalCoder))
|
219
166
|
define_store_with_no_attributes(coder: ColumnCoder.new(MarshalCoder))
|
220
167
|
define_store_with_partial_attributes(coder: ColumnCoder.new(MarshalCoder))
|
168
|
+
define_stores_with_prefix_and_suffix(coder: ColumnCoder.new(MarshalCoder))
|
221
169
|
end
|
222
170
|
|
223
171
|
Models = [
|
@@ -227,6 +175,3 @@ Models = [
|
|
227
175
|
JsonTypedStoreModel,
|
228
176
|
MarshalTypedStoreModel
|
229
177
|
]
|
230
|
-
Models << MysqlRegularARModel if defined?(MysqlRegularARModel)
|
231
|
-
Models << PostgresqlRegularARModel if defined?(PostgresqlRegularARModel)
|
232
|
-
Models << PostgresJsonTypedStoreModel if defined?(PostgresJsonTypedStoreModel)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-typedstore
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jean Boussier
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-05-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '6.1'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '6.1'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,20 +66,6 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '3'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: coveralls
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - "~>"
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - "~>"
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
83
69
|
- !ruby/object:Gem::Dependency
|
84
70
|
name: sqlite3
|
85
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,34 +80,6 @@ dependencies:
|
|
94
80
|
- - "~>"
|
95
81
|
- !ruby/object:Gem::Version
|
96
82
|
version: '1'
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: pg
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - "~>"
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '0.18'
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - "~>"
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '0.18'
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: mysql2
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - ">"
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: '0.3'
|
118
|
-
type: :development
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
requirements:
|
122
|
-
- - ">"
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: '0.3'
|
125
83
|
- !ruby/object:Gem::Dependency
|
126
84
|
name: database_cleaner
|
127
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -151,10 +109,8 @@ files:
|
|
151
109
|
- README.md
|
152
110
|
- Rakefile
|
153
111
|
- activerecord-typedstore.gemspec
|
154
|
-
- gemfiles/Gemfile.ar-5.0
|
155
|
-
- gemfiles/Gemfile.ar-5.2
|
156
|
-
- gemfiles/Gemfile.ar-6.0
|
157
112
|
- gemfiles/Gemfile.ar-6.1
|
113
|
+
- gemfiles/Gemfile.ar-7.0
|
158
114
|
- gemfiles/Gemfile.ar-master
|
159
115
|
- lib/active_record/typed_store.rb
|
160
116
|
- lib/active_record/typed_store/behavior.rb
|
@@ -190,7 +146,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
190
146
|
- !ruby/object:Gem::Version
|
191
147
|
version: '0'
|
192
148
|
requirements: []
|
193
|
-
rubygems_version: 3.
|
149
|
+
rubygems_version: 3.3.7
|
194
150
|
signing_key:
|
195
151
|
specification_version: 4
|
196
152
|
summary: Add type casting and full method attributes support to АctiveRecord store
|
data/gemfiles/Gemfile.ar-5.0
DELETED