enum_help 0.0.10 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/enum_help/i18n.rb +4 -8
- data/lib/enum_help/simple_form.rb +8 -1
- data/lib/enum_help/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d041b071b80798a39880cc1fa72bbd4dcf329849
|
4
|
+
data.tar.gz: f0477e5d2c29fa3dcbcf580f78b53cc4c8f7dbc7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fce939611966166b5e82749f53ac2d1386780576d3010c871afcfcad31482403696f717714bd667f3b26055c2951e27bc89ee4ef7d472ded74cdd63fd50876ed
|
7
|
+
data.tar.gz: 59f664a9598971f560078870073bede73b811c03f1fdadfefe84b7baa50a86a17e40c6fd7988aa53084b3175ab1774062cbc757d79d93dcaeda51bc4beabc584
|
data/lib/enum_help/i18n.rb
CHANGED
@@ -41,14 +41,10 @@ module EnumHelp
|
|
41
41
|
collection_i18n_method_name = "#{collection_method_name}_i18n"
|
42
42
|
|
43
43
|
klass.instance_eval <<-METHOD, __FILE__, __LINE__
|
44
|
-
def #{collection_i18n_method_name}
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
collection.map do |label, value|
|
50
|
-
[::EnumHelp::Helper.translate_enum_label(self, :#{attr_name}, label), value]
|
51
|
-
end.to_h
|
44
|
+
def #{collection_i18n_method_name}
|
45
|
+
#{collection_method_name}.collect do |label, _|
|
46
|
+
[label, ::EnumHelp::Helper.translate_enum_label(self, :#{attr_name}, label)]
|
47
|
+
end.to_h.with_indifferent_access
|
52
48
|
end
|
53
49
|
METHOD
|
54
50
|
end
|
@@ -31,7 +31,14 @@ module EnumHelp
|
|
31
31
|
enum = input_options[:collection] || @builder.options[:collection]
|
32
32
|
raise "Attribute '#{attribute_name}' has no enum class" unless enum ||= object.class.send(attribute_name.to_s.pluralize)
|
33
33
|
|
34
|
-
|
34
|
+
enum = enum.keys if enum.is_a? Hash
|
35
|
+
|
36
|
+
collect = begin
|
37
|
+
collection = object.class.send("#{attribute_name.to_s.pluralize}_i18n")
|
38
|
+
collection.slice!(*enum) if enum
|
39
|
+
collection.invert.to_a
|
40
|
+
end
|
41
|
+
|
35
42
|
# collect.unshift [args.last[:prompt],''] if args.last.is_a?(Hash) && args.last[:prompt]
|
36
43
|
|
37
44
|
if respond_to?(:input_options)
|
data/lib/enum_help/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: enum_help
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lester Zhao
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-09-
|
11
|
+
date: 2014-09-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|