activemodel_flags 0.1.2 → 0.1.3
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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7764714884ff55e559457949d1eca5d95b6a4215
|
4
|
+
data.tar.gz: e93d6b83fb444877e407ed4dcbb2c06276859daa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2f12d9ac13dad2223cfe0d16a265d8437766294d90dada955d08f06c1d52d4a3d5d90f90b6e7f4852ba7042f87e4b3d07edf687c3464174a8fd4fad4768d135
|
7
|
+
data.tar.gz: 87c27aa45c410baa5fb63e524a89521b8e9c1d633c395a4653a010e7a9887b658faca6156f7837ad37160260c85e4cce42d855847d3a09a8051de5aaddbbc5b8
|
@@ -17,24 +17,24 @@ module ActivemodelFlags
|
|
17
17
|
after_initialize :init_flags
|
18
18
|
|
19
19
|
scope :that_have?, -> (key) {
|
20
|
-
where("flags LIKE '%\"#{key}\":true%'")
|
20
|
+
where("#{table_name}.flags LIKE '%\"#{key}\":true%'")
|
21
21
|
}
|
22
22
|
scope :that_havent?, -> (key) {
|
23
|
-
where("flags NOT LIKE '%\"#{key}\":true%'")
|
23
|
+
where("#{table_name}.flags NOT LIKE '%\"#{key}\":true%'")
|
24
24
|
}
|
25
25
|
scope :that_have_not?, -> (key) { that_havent?(key) }
|
26
26
|
|
27
27
|
scope :that_have_any_flags, -> {
|
28
|
-
where("flags != '{}' AND flags IS NOT NULL")
|
28
|
+
where("#{table_name}.flags != '{}' AND #{table_name}.flags IS NOT NULL")
|
29
29
|
}
|
30
30
|
|
31
31
|
scope :all_have!, -> (flag) {
|
32
32
|
self.reset_flags!(flag)
|
33
|
-
self.update_all("flags = REPLACE(flags, '}', '\"#{flag}\":true}')")
|
33
|
+
self.update_all("flags = REPLACE(#{table_name}.flags, '}', '\"#{flag}\":true}')")
|
34
34
|
}
|
35
35
|
scope :all_have_not!, -> (flag) {
|
36
36
|
self.reset_flags!(flag)
|
37
|
-
self.update_all("flags = REPLACE(flags, '}', '\"#{flag}\":false}')")
|
37
|
+
self.update_all("flags = REPLACE(#{table_name}.flags, '}', '\"#{flag}\":false}')")
|
38
38
|
}
|
39
39
|
|
40
40
|
def self.flags_used
|
@@ -1,11 +1,7 @@
|
|
1
1
|
class AddFlagsTo<%= table_name.camelize %> < ActiveRecord::Migration
|
2
2
|
|
3
3
|
def up
|
4
|
-
add_column :<%= table_name %>, :flags, :text
|
5
|
-
|
6
|
-
<%= class_name.camelize.singularize %>.all.each do |obj|
|
7
|
-
obj.update!(flags: {})
|
8
|
-
end
|
4
|
+
add_column :<%= table_name %>, :flags, :text, default: '{}'
|
9
5
|
end
|
10
6
|
|
11
7
|
def down
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activemodel_flags
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jay El-Kaake
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-11-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|