activemodel_flags 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d1e1bded5e5954620eb9b8f3ffb1e383eda9f22a
4
- data.tar.gz: fcfb03822648efd517a2d0094700b746c937d528
3
+ metadata.gz: 7764714884ff55e559457949d1eca5d95b6a4215
4
+ data.tar.gz: e93d6b83fb444877e407ed4dcbb2c06276859daa
5
5
  SHA512:
6
- metadata.gz: 6ee4140d324b8cbd4d5c3696995e4f0ac942ed8ba2d966f91d5a00b40dbd354ee55359bbca3ca1521cfacea9ae1ce40d8f4a37d979af039f2d4e3ae4390b52f9
7
- data.tar.gz: 503dc08d6f6a6b50fb50929356d2015d9a59c235fd75114f3575a64ba8b0bfb16c5c454aeb344606fecbcfc01a515955a5030d6790adee0c8a5c657ea13131f0
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,3 +1,3 @@
1
1
  module ActivemodelFlags
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
@@ -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.2
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-08-20 00:00:00.000000000 Z
11
+ date: 2016-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails