act_with_bag 0.5.5 → 0.5.6
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/.travis.yml +6 -4
- data/Appraisals +4 -4
- data/Gemfile +2 -1
- data/README.md +9 -5
- data/act_with_bag.gemspec +0 -1
- data/gemfiles/rails_5.1.gemfile +1 -1
- data/gemfiles/rails_5.2.gemfile +1 -1
- data/lib/act_with_bag.rb +13 -0
- data/lib/act_with_bag/version.rb +2 -1
- data/test/test_helper.rb +4 -4
- metadata +2 -3
- data/gemfiles/rails_5.0.gemfile +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f9d944ab63f66ac27dbe26f203d382255df7c6acde3559338cb1f05cb3dd420d
|
4
|
+
data.tar.gz: e1eabac9f4a018bf19c82d9efcff941d540a50a49099504cf70b88dedceb8dd6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3d27f9b7ca2f6ceed944e6150faf92ed2414b537d50ebdbef7b87e5558a3315f1e32c7c2910b6201857e871850f8af25dae5932342946f630f41abe108cbd0d
|
7
|
+
data.tar.gz: 61492eb20e6b1ddb96086c5e03db7e30734cb3067619cb0d9a58144ac30c9905586f1e55caee67eaf06a4a778b6e8320fd084758fc5174bf297b25bd07b3f7d5
|
data/.travis.yml
CHANGED
@@ -2,20 +2,22 @@ language: ruby
|
|
2
2
|
sudo: false
|
3
3
|
|
4
4
|
bundler_args: --without production
|
5
|
-
before_install:
|
5
|
+
#before_install:
|
6
|
+
#- gem update bundler --no-document
|
7
|
+
#- gem update bundler --no-rdoc --no-ri
|
6
8
|
script: "bundle exec rake test"
|
7
9
|
|
8
10
|
rvm:
|
11
|
+
- 2.6.0
|
12
|
+
- 2.5.1
|
9
13
|
# - 1.9.3
|
10
14
|
## - 2.2.3
|
11
15
|
# - 2.3.1
|
12
16
|
## - 2.4.1
|
13
|
-
- 2.5.1
|
14
17
|
|
15
18
|
gemfile:
|
16
|
-
- gemfiles/rails_5.0.gemfile
|
17
|
-
- gemfiles/rails_5.1.gemfile
|
18
19
|
- gemfiles/rails_5.2.gemfile
|
20
|
+
- gemfiles/rails_5.1.gemfile
|
19
21
|
|
20
22
|
matrix:
|
21
23
|
# exclude:
|
data/Appraisals
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -14,13 +14,13 @@ Install (migrate) one bag as a text field in a table to collect many fields.
|
|
14
14
|
Additional fields or removal of them are easy;
|
15
15
|
no migrations are required for them.
|
16
16
|
|
17
|
-
Keep in mind that the collection is kept in a YAML bag,
|
18
|
-
SQL commands can't access the bag fields.
|
17
|
+
Keep in mind that the collection is kept in a YAML bag,
|
18
|
+
i.e. SQL commands can't access the bag fields.
|
19
19
|
|
20
20
|
Boolean and Date fields require explicit typing.
|
21
21
|
|
22
22
|
Fields without typing accept any values which YAML can handle
|
23
|
-
(e.g. @order.
|
23
|
+
(e.g. @order.colors = ['red', 'yellow']).
|
24
24
|
|
25
25
|
Types :integer, :float and :string
|
26
26
|
forces a conversion (.to_i, .to_f, .to_s) before storing the value,
|
@@ -40,13 +40,17 @@ Obsolete fields are deleted before_save by:
|
|
40
40
|
Warning
|
41
41
|
=======
|
42
42
|
|
43
|
-
Please add a:
|
43
|
+
1. Please add a:
|
44
44
|
|
45
45
|
serialize :bag, Hash
|
46
46
|
|
47
47
|
to each subclass accessing a bag field from a superclass.
|
48
48
|
Using an "add_to_bag" in the subclass obsoletes the "serialize".
|
49
49
|
|
50
|
+
2. delete_from_bag just delete the field from the record being saved.
|
51
|
+
Other records are untouched,
|
52
|
+
i.e. the value of the field will be kept in the database.
|
53
|
+
|
50
54
|
|
51
55
|
Example
|
52
56
|
=======
|
@@ -88,4 +92,4 @@ Test
|
|
88
92
|
|
89
93
|
rake
|
90
94
|
|
91
|
-
Copyright (c) 2009-
|
95
|
+
Copyright (c) 2009-2019 [Dittmar Krall], released under the MIT license
|
data/act_with_bag.gemspec
CHANGED
data/gemfiles/rails_5.1.gemfile
CHANGED
data/gemfiles/rails_5.2.gemfile
CHANGED
data/lib/act_with_bag.rb
CHANGED
@@ -84,6 +84,19 @@ class << ActiveRecord::Base
|
|
84
84
|
def add_accessor(baggie, type)
|
85
85
|
accessor = baggie.to_s
|
86
86
|
return if accessor_present?(accessor)
|
87
|
+
#MARS patch, new:
|
88
|
+
#
|
89
|
+
# The @baggies field is indispensable. Otherwise mistakes in renaming
|
90
|
+
# or deleting baggies (without renaming/deleting) the value entry from the
|
91
|
+
# bag, e. g. via delete_from_bag) cannot be detected in a clean way.
|
92
|
+
# Detecting the accessor would be not sufficient, as the accessor may be
|
93
|
+
# created by ActiveRecord::Base or the derived model and it may be
|
94
|
+
# doing completely other things (e. g. accessing a database column).
|
95
|
+
#
|
96
|
+
@baggies ||= {}
|
97
|
+
baggies = ( @baggies[self.to_s.underscore.to_sym] ||= {} )
|
98
|
+
baggies[ baggie ] = type
|
99
|
+
#END
|
87
100
|
|
88
101
|
type_sym = type.to_sym
|
89
102
|
typing = {integer: '.to_i', float: '.to_f',
|
data/lib/act_with_bag/version.rb
CHANGED
data/test/test_helper.rb
CHANGED
@@ -4,10 +4,10 @@ require 'rubygems'
|
|
4
4
|
require 'minitest/autorun'
|
5
5
|
require 'active_record'
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
SimpleCov.start do
|
8
|
+
add_filter 'test'
|
9
|
+
command_name 'Minitest'
|
10
|
+
end
|
11
11
|
|
12
12
|
ActiveRecord::Base.establish_connection({
|
13
13
|
adapter: 'sqlite3',
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: act_with_bag
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dittmar Krall
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-02-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -69,7 +69,6 @@ files:
|
|
69
69
|
- README.md
|
70
70
|
- Rakefile
|
71
71
|
- act_with_bag.gemspec
|
72
|
-
- gemfiles/rails_5.0.gemfile
|
73
72
|
- gemfiles/rails_5.1.gemfile
|
74
73
|
- gemfiles/rails_5.2.gemfile
|
75
74
|
- lib/act_with_bag.rb
|
data/gemfiles/rails_5.0.gemfile
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
# This file was generated by Appraisal
|
2
|
-
|
3
|
-
source "https://rubygems.org"
|
4
|
-
|
5
|
-
gem "rails", "~> 5.0.0"
|
6
|
-
gem "dryer-config", "~> 5.0.0"
|
7
|
-
|
8
|
-
group :test do
|
9
|
-
gem "observr"
|
10
|
-
gem "simplecov", require: false
|
11
|
-
gem "minitest"
|
12
|
-
gem "capybara"
|
13
|
-
gem "sqlite3"
|
14
|
-
end
|
15
|
-
|
16
|
-
gemspec path: "../"
|