enumerize 2.0.1 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +11 -5
- data/CHANGELOG.md +6 -0
- data/lib/enumerize/activerecord.rb +20 -0
- data/lib/enumerize/version.rb +1 -1
- data/test/activerecord_test.rb +9 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e11fc29306be657be93429d810d7d38d15633f7
|
4
|
+
data.tar.gz: 2d2f0590533e31c71432f9f1a35e0cf8e8120f50
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1a583881a025b925000573c7602bbdd118485544c4fa5f3b08cc740c12e780b297013b5ccee04b4d49a1d9fbb93e7691ac0cc5f9c203fefc587cba9f35cccc3
|
7
|
+
data.tar.gz: 738971e9f0f3b253df6ae23c9d36fdf628b543cfafc8304b90b871f896b131ff491d35a1b92e81f6d34b4f3d69f97afa7798ddf6adb80a99a9835c0ed410c084
|
data/.travis.yml
CHANGED
@@ -7,12 +7,18 @@ gemfile:
|
|
7
7
|
- Gemfile.rails42
|
8
8
|
- Gemfile.mongo_mapper
|
9
9
|
rvm:
|
10
|
-
- 2.2.
|
11
|
-
- 2.3.
|
12
|
-
-
|
10
|
+
- 2.2.6
|
11
|
+
- 2.3.3
|
12
|
+
- ruby-head
|
13
|
+
- jruby-9.1.6.0
|
13
14
|
matrix:
|
14
15
|
allow_failures:
|
15
|
-
- gemfile: Gemfile
|
16
|
-
rvm:
|
16
|
+
- gemfile: Gemfile.rails42
|
17
|
+
rvm: ruby-head
|
18
|
+
- gemfile: Gemfile.mongo_mapper
|
19
|
+
rvm: ruby-head
|
20
|
+
branches:
|
21
|
+
only:
|
22
|
+
- master
|
17
23
|
notifications:
|
18
24
|
email: false
|
data/CHANGELOG.md
CHANGED
@@ -17,6 +17,12 @@ module Enumerize
|
|
17
17
|
|
18
18
|
# https://github.com/brainspec/enumerize/issues/111
|
19
19
|
require 'enumerize/hooks/uniqueness'
|
20
|
+
|
21
|
+
unless options[:multiple]
|
22
|
+
decorate_attribute_type(name, :enumerize) do |subtype|
|
23
|
+
Type.new(enumerized_attributes[name], subtype)
|
24
|
+
end
|
25
|
+
end
|
20
26
|
end
|
21
27
|
end
|
22
28
|
end
|
@@ -59,5 +65,19 @@ module Enumerize
|
|
59
65
|
super(updates)
|
60
66
|
end
|
61
67
|
end
|
68
|
+
|
69
|
+
class Type < ActiveRecord::Type::Value
|
70
|
+
delegate :type, to: :@subtype
|
71
|
+
|
72
|
+
def initialize(attr, subtype)
|
73
|
+
@attr = attr
|
74
|
+
@subtype = subtype
|
75
|
+
end
|
76
|
+
|
77
|
+
def serialize(value)
|
78
|
+
v = @attr.find_value(value)
|
79
|
+
v && v.value
|
80
|
+
end
|
81
|
+
end
|
62
82
|
end
|
63
83
|
end
|
data/lib/enumerize/version.rb
CHANGED
data/test/activerecord_test.rb
CHANGED
@@ -469,4 +469,13 @@ describe Enumerize::ActiveRecordSupport do
|
|
469
469
|
user.reload
|
470
470
|
user.status.must_equal nil
|
471
471
|
end
|
472
|
+
|
473
|
+
it 'supports AR types serialization' do
|
474
|
+
User.delete_all
|
475
|
+
|
476
|
+
type = User.type_for_attribute('status')
|
477
|
+
type.must_be_instance_of Enumerize::ActiveRecordSupport::Type
|
478
|
+
serialized = type.serialize('blocked')
|
479
|
+
serialized.must_equal 2
|
480
|
+
end
|
472
481
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: enumerize
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergey Nartimov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-03-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -107,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
107
107
|
version: '0'
|
108
108
|
requirements: []
|
109
109
|
rubyforge_project:
|
110
|
-
rubygems_version: 2.
|
110
|
+
rubygems_version: 2.6.11
|
111
111
|
signing_key:
|
112
112
|
specification_version: 4
|
113
113
|
summary: Enumerated attributes with I18n and ActiveRecord/Mongoid/MongoMapper support
|