rails_string_enum 0.1.2 → 0.2.0
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 +4 -4
- data/README.md +6 -3
- data/lib/rails_string_enum/string_enum.rb +3 -7
- data/lib/rails_string_enum/version.rb +1 -1
- data/rails_string_enum.gemspec +3 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f8f5d799d80ef60d8cb5fddd1fb78e8e0993fae0
|
4
|
+
data.tar.gz: 06de1d230ba2e95529ce9690c8f635268bd01971
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 57c1721baad65c2452550bbd173824bdbf38f641728b1c3e34e76753a464650072caaac6b0bbee379280027934bef1677705285fb09988a728065834079710b3
|
7
|
+
data.tar.gz: f991aa54e4dcb8c8a57d42a6c4c08fda106a07327627df471d9f34f7ad89764be1721120ecf6394b59d7fbf2a506049a630d78e799abca4a11911f2fed3f0b3f
|
data/README.md
CHANGED
@@ -11,6 +11,9 @@ Add this line to your application's Gemfile:
|
|
11
11
|
|
12
12
|
Tested on Rails 4.2, ruby 2.2
|
13
13
|
|
14
|
+
#### Broken changes from 0.1 to 0.2
|
15
|
+
`Product::COLOR::GREEN => Product::GREEN`
|
16
|
+
|
14
17
|
#### Native postgresql enum (migrations)
|
15
18
|
```ruby
|
16
19
|
|
@@ -68,7 +71,7 @@ class Product < ActiveRecord::Base
|
|
68
71
|
string_enum :color, %w(red green yellow black white), scopes: true # default false
|
69
72
|
|
70
73
|
def self.colored
|
71
|
-
where.not(color: [
|
74
|
+
where.not(color: [BLACK, WHITE])
|
72
75
|
end
|
73
76
|
end
|
74
77
|
|
@@ -77,8 +80,8 @@ class Page < ActiveRecord::Base
|
|
77
80
|
end
|
78
81
|
|
79
82
|
Product::COLORS # => ["red", "green", "yellow"]
|
80
|
-
Product::
|
81
|
-
Product::
|
83
|
+
Product::RED # => "red"
|
84
|
+
Product::GREEN # => "green"
|
82
85
|
|
83
86
|
@product = Product.new
|
84
87
|
@product.color_i18n # => nil
|
@@ -11,13 +11,6 @@ module RailsStringEnum
|
|
11
11
|
const_name_all_values = name.to_s.pluralize.upcase
|
12
12
|
const_set const_name_all_values, enums.map(&:to_s)
|
13
13
|
|
14
|
-
# create constant for each value
|
15
|
-
# Product::COLOR::RED # => "red"
|
16
|
-
# Product::COLOR::GREEN #=> "green"
|
17
|
-
new_module = const_set name.to_s.upcase, Module.new
|
18
|
-
enums.each { |const| new_module.const_set(const.to_s.upcase, const.to_s) }
|
19
|
-
|
20
|
-
|
21
14
|
klass = self
|
22
15
|
enums.each do |value|
|
23
16
|
# def red?() color == 'red' end
|
@@ -33,6 +26,9 @@ module RailsStringEnum
|
|
33
26
|
klass.send(:detect_enum_conflict!, name, value, true)
|
34
27
|
klass.scope value, -> { klass.where name => value }
|
35
28
|
end
|
29
|
+
|
30
|
+
# Product::RED #=> "red"
|
31
|
+
const_set value.to_s.upcase, value.to_s
|
36
32
|
end
|
37
33
|
|
38
34
|
define_attr_i18n_method(self, name, i18n_scope)
|
data/rails_string_enum.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ["andrey@ermolaev.me"]
|
11
11
|
|
12
12
|
spec.summary = %q{support in rails db enums or string (using as flexible enum)}
|
13
|
-
spec.description = %q{migration methods for postgresql, internationalization, simple_form}
|
13
|
+
spec.description = %q{migration methods for postgresql enum, internationalization, simple_form}
|
14
14
|
spec.homepage = 'https://github.com/ermolaev/rails_string_enum'
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
@@ -23,4 +23,6 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.add_development_dependency "rake", "~> 10.0"
|
24
24
|
|
25
25
|
spec.add_dependency "activerecord", "~> 4.2"
|
26
|
+
|
27
|
+
spec.required_ruby_version = '~> 2.0'
|
26
28
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_string_enum
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ermolaev
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-05-
|
11
|
+
date: 2015-05-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,7 +52,7 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '4.2'
|
55
|
-
description: migration methods for postgresql, internationalization, simple_form
|
55
|
+
description: migration methods for postgresql enum, internationalization, simple_form
|
56
56
|
email:
|
57
57
|
- andrey@ermolaev.me
|
58
58
|
executables: []
|
@@ -81,9 +81,9 @@ require_paths:
|
|
81
81
|
- lib
|
82
82
|
required_ruby_version: !ruby/object:Gem::Requirement
|
83
83
|
requirements:
|
84
|
-
- - "
|
84
|
+
- - "~>"
|
85
85
|
- !ruby/object:Gem::Version
|
86
|
-
version: '0'
|
86
|
+
version: '2.0'
|
87
87
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
88
|
requirements:
|
89
89
|
- - ">="
|