ruby_enum 0.5.0.beta3 → 0.5.0.beta4
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/Gemfile.lock +1 -1
- data/lib/ruby_enum/active_model.rb +31 -0
- data/lib/ruby_enum/railtie.rb +1 -0
- data/lib/ruby_enum.rb +1 -0
- data/ruby_enum.gemspec +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5aacb47f8d4e6115b070b474568cc6b457998c7d
|
4
|
+
data.tar.gz: c583a662608e18b6f2ef4c3f48a975a809114103
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8f965c9a16af050a91428380fadaf3fa089615c336da73b4080856503bcb92f684efb8ca405f2f45d36f8dd2ea49ae564f8f5dfa8f2ed978e1a0e00ad2f9ef7c
|
7
|
+
data.tar.gz: 3153dd8c22be99256e514f31effd81fc13b984b7d2a7120e54dd51efd50c99a965e99ea0e77c00844612ecc13b84b244b223c5cc37aeef91e524a1d024a5982f
|
data/Gemfile.lock
CHANGED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'active_support/concern'
|
2
|
+
|
3
|
+
module RubyEnum
|
4
|
+
module ActiveModel
|
5
|
+
module AttrEnum
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
|
8
|
+
def assign_attributes(new_attributes, optsions = {})
|
9
|
+
enumeration_attrs = self.class.attr_enums
|
10
|
+
|
11
|
+
new_attributes.each do |k, v|
|
12
|
+
enum_attr = enumeration_attrs[k]
|
13
|
+
|
14
|
+
if enum_attr.present? && _is_not_enum?(v)
|
15
|
+
enum_class_name = enum_attr[:class_name]
|
16
|
+
enum_class = Object.const_get enum_class_name
|
17
|
+
new_attributes[k] = enum_class.find_by_value(v)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
super
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def _is_not_enum?(value)
|
27
|
+
!value.class.ancestors.include? RubyEnum
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/ruby_enum/railtie.rb
CHANGED
data/lib/ruby_enum.rb
CHANGED
data/ruby_enum.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_enum
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.0.
|
4
|
+
version: 0.5.0.beta4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lefteris Laskaridis
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -83,6 +83,7 @@ files:
|
|
83
83
|
- bin/console
|
84
84
|
- bin/setup
|
85
85
|
- lib/ruby_enum.rb
|
86
|
+
- lib/ruby_enum/active_model.rb
|
86
87
|
- lib/ruby_enum/active_record.rb
|
87
88
|
- lib/ruby_enum/railtie.rb
|
88
89
|
- lib/ruby_enum/rspec.rb
|