tag_columns 0.1.0 → 0.1.1

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: 500aa16eedb432395f0e65734d95cdc1e0e18569
4
- data.tar.gz: bac6b106f88fd638e8ae32fa94320f43b16823c0
3
+ metadata.gz: 70fdfc0271ea3299c00a03617d8ac8ab3c1aa922
4
+ data.tar.gz: 59f0c97926eb432b77ee06449d0c8ae185bc7af9
5
5
  SHA512:
6
- metadata.gz: 93477456535a921860122c33b2ba77693f32ed0bd3acf9a0add40f59ab0c8c86e04ff294afd8fef59cb1217abad16bdc0b766359e6478af39884907781cf1bd0
7
- data.tar.gz: f3663c9604bc22ba0ec91a3d71c372677d773abc0cd41dd8b731d346e298de81303721408b84974489ff9ab6692c767420c90ea90fcaf99c16f002a76304ccae
6
+ metadata.gz: a6c2a2898846a98c5aa13356866d1cddd709d0a2025799bd3166bcedbdd0c2b92b46756bf4855e22a9a5c040c486fc34d4f25b6c4a212b9e0caef9caca102159
7
+ data.tar.gz: 2474138516e22364189e4a84339ff80226391ca44be868904a00e6ddb3c03cf28676a7ebfb575761ea76238a79b183c974ae9e76dfec03a4823f6a91de7e7f8c
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tag_columns (0.1.0)
4
+ tag_columns (0.1.1)
5
5
  activesupport
6
6
 
7
7
  GEM
@@ -1,3 +1,3 @@
1
1
  module TagColumns
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
data/lib/tag_columns.rb CHANGED
@@ -20,27 +20,27 @@ module TagColumns
20
20
  @tag_columns.each do |column_name, initialized|
21
21
  next if initialized
22
22
 
23
- column_name_plural = column_name.pluralize
23
+ method_name = column_name.downcase
24
24
  quoted_column_name = "#{quoted_table_name}.#{connection.quote_column_name column_name}"
25
25
 
26
- scope :"with_any_#{column_name}", ->(*tags) { where "#{quoted_column_name} && ARRAY[?]::varchar[]", tag_columns_sanitize_list(tags) }
27
- scope :"with_all_#{column_name}", ->(*tags) { where "#{quoted_column_name} @> ARRAY[?]::varchar[]", tag_columns_sanitize_list(tags) }
28
- scope :"without_any_#{column_name}", ->(*tags) { where.not "#{quoted_column_name} && ARRAY[?]::varchar[]", tag_columns_sanitize_list(tags) }
29
- scope :"without_all_#{column_name}", ->(*tags) { where.not "#{quoted_column_name} @> ARRAY[?]::varchar[]", tag_columns_sanitize_list(tags) }
26
+ scope :"with_any_#{method_name}", ->(*tags) { where "#{quoted_column_name} && ARRAY[?]::varchar[]", tag_columns_sanitize_list(tags) }
27
+ scope :"with_all_#{method_name}", ->(*tags) { where "#{quoted_column_name} @> ARRAY[?]::varchar[]", tag_columns_sanitize_list(tags) }
28
+ scope :"without_any_#{method_name}", ->(*tags) { where.not "#{quoted_column_name} && ARRAY[?]::varchar[]", tag_columns_sanitize_list(tags) }
29
+ scope :"without_all_#{method_name}", ->(*tags) { where.not "#{quoted_column_name} @> ARRAY[?]::varchar[]", tag_columns_sanitize_list(tags) }
30
30
 
31
31
  before_validation Proc.new { self[column_name] = self.class.tag_columns_sanitize_list(self[column_name]) }
32
32
 
33
- define_method :"has_any_#{column_name_plural}?" do |*values|
33
+ define_method :"has_any_#{method_name}?" do |*values|
34
34
  values = self.class.tag_columns_sanitize_list(values)
35
- existing = self[column_name] || []
35
+ existing = self.class.tag_columns_sanitize_list(self[column_name] || [])
36
36
  (values & existing).present?
37
37
  end
38
38
 
39
- alias_method :"has_#{column_name_plural}?", :"has_any_#{column_name_plural}?"
39
+ alias_method :"has_#{method_name.singularize}?", :"has_any_#{method_name}?"
40
40
 
41
- define_method :"has_all_#{column_name_plural}?" do |*values|
41
+ define_method :"has_all_#{method_name}?" do |*values|
42
42
  values = self.class.tag_columns_sanitize_list(values)
43
- existing = self[column_name] || []
43
+ existing = self.class.tag_columns_sanitize_list(self[column_name] || [])
44
44
  (values & existing).size == values.size
45
45
  end
46
46
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tag_columns
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Hopkins