enumerize_with_groups 0.1.1 → 0.2.0

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: 2c7a16c357acab4db2ab2249b31ea72a43826a08
4
- data.tar.gz: 4a0e4cd17688530472e2622ca4183262cfb7bbb6
3
+ metadata.gz: 59506b929f4cfd75b0fe4093318008574ea6b193
4
+ data.tar.gz: 9f4883d1eee279a916cef4d1a3ed90dcbb47ebb7
5
5
  SHA512:
6
- metadata.gz: 60e395c044a8486f69ebc84c82e776f0dec09c6ceb31d0b37c5627e6fa37f563194aebc6dd50e58c28bffbdd257c5b2e337f98ef0c0ab341bf45d53d8db7ccf0
7
- data.tar.gz: 8a687edd3dd6bff7cce0591da07416d8b63772208452ab9832e63c9d355b234ad6fafd524f2a98a45515ea0b989ee98e5c16d44d443311ae73ca4100f6fa5c57
6
+ metadata.gz: 1997524375a224fabbe66cf33e7a0bafd79574cf7b9ce39243b6cf0c747977bec0c3a9fdeb98a788289c27e51194ec3694efa2dcaa1d4e12d488813e967cbaec
7
+ data.tar.gz: ef1b50fee050c299b4ae61dcc534cc1ed7afa53d27d185cf027a10e4c059636212d861c971eda2f8e4d1da4737381110535aed9ca8dad6ebd0e2a6ac84427974
data/README.md CHANGED
@@ -43,6 +43,9 @@ ShoppingCart.item_groups => # {
43
43
 
44
44
  ShoppingCart.item_fruit => # [:banana, :apple]
45
45
 
46
+ ShoppingCart.last.in_item_fruit? => # true
47
+
48
+
46
49
  # if you use `ActiveRecord::Base`
47
50
  ShoppingCart.item_fruit_scope # ShoppingCart.where(item: %w(banana apple))
48
51
 
@@ -31,6 +31,7 @@ Gem::Specification.new do |spec|
31
31
  spec.add_development_dependency "rake", "~> 10.0"
32
32
  spec.add_development_dependency "rspec"
33
33
  spec.add_development_dependency "activerecord"
34
+ spec.add_development_dependency "pry"
34
35
 
35
36
  spec.add_runtime_dependency "enumerize"
36
37
  end
@@ -1,3 +1,3 @@
1
1
  module EnumerizeWithGroups
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -25,6 +25,13 @@ module EnumerizeWithGroups
25
25
  items
26
26
  end
27
27
 
28
+ define_method("in_#{name}_#{key}?") do
29
+ values = options[:groups][key]
30
+ fail "You have to define #{key} as group" unless values.is_a?(Array)
31
+
32
+ values.map(&:to_s).include?(self.public_send(name))
33
+ end
34
+
28
35
  if self.ancestors.include?(ActiveRecord::Base)
29
36
  scope scope_name, ->{ where(name => items) }
30
37
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: enumerize_with_groups
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - lcp
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-08-04 00:00:00.000000000 Z
11
+ date: 2015-09-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry
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'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: enumerize
71
85
  requirement: !ruby/object:Gem::Requirement