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 +4 -4
- data/README.md +3 -0
- data/enumerize_with_groups.gemspec +1 -0
- data/lib/enumerize_with_groups/version.rb +1 -1
- data/lib/enumerize_with_groups.rb +7 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 59506b929f4cfd75b0fe4093318008574ea6b193
|
4
|
+
data.tar.gz: 9f4883d1eee279a916cef4d1a3ed90dcbb47ebb7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1997524375a224fabbe66cf33e7a0bafd79574cf7b9ce39243b6cf0c747977bec0c3a9fdeb98a788289c27e51194ec3694efa2dcaa1d4e12d488813e967cbaec
|
7
|
+
data.tar.gz: ef1b50fee050c299b4ae61dcc534cc1ed7afa53d27d185cf027a10e4c059636212d861c971eda2f8e4d1da4737381110535aed9ca8dad6ebd0e2a6ac84427974
|
data/README.md
CHANGED
@@ -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
|
@@ -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.
|
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-
|
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
|