enum_help 0.0.15 → 0.0.16
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 +25 -0
- data/lib/enum_help/i18n.rb +2 -2
- data/lib/enum_help/simple_form.rb +3 -4
- 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: 5b76ebfec1adf5d496385557f9425e1e1a95554c
|
4
|
+
data.tar.gz: eb49a08c37113ebf0852cad91e2f774d94493f47
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 80eb30b5f104314e567b1af238a1bb9f5122b4a35701f68788f287c57c84da92178bf6fd3431ba2e40b0a68748c451ecea5500137bc07d9e1bdd332543a89a78
|
7
|
+
data.tar.gz: 6784941159e554668851e44dfa4e4ad8f28b803d54c55e555a16f148c941bfbbba7958f2d52636375c397b0bf23145f700e08fd326f7b1c33096753cd641e55f
|
data/README.md
CHANGED
@@ -8,6 +8,31 @@ As you know in Rails 4.1.0 , ActiveRecord supported Enum method. But it doesn't
|
|
8
8
|
|
9
9
|
This gem can help you work fine with Enum feather, I18n and simple_form
|
10
10
|
|
11
|
+
## Breaking Changes
|
12
|
+
|
13
|
+
Version 0.0.15 changes the behaviour of namespaced modules as per [this commit](https://github.com/zmbacker/enum_help/commit/fd1c09bcc5402b97bbf4d35313ce84cdffbe47d3): standard en.yml structures for enums `Foo::Bar::Baz#abc` and `Foo::Bar::Bat#def` change from
|
14
|
+
|
15
|
+
enums:
|
16
|
+
foo/bar/baz:
|
17
|
+
abc:
|
18
|
+
lorem: 'Ipsum'
|
19
|
+
foo/bar/bat:
|
20
|
+
abc:
|
21
|
+
lorem: 'Ipsum'
|
22
|
+
|
23
|
+
To
|
24
|
+
|
25
|
+
enums:
|
26
|
+
foo:
|
27
|
+
bar:
|
28
|
+
baz:
|
29
|
+
abc:
|
30
|
+
lorem: 'Ipsum'
|
31
|
+
bat:
|
32
|
+
abc:
|
33
|
+
lorem: 'Ipsum'
|
34
|
+
|
35
|
+
For different I18n backends, adjust accordingly as namespaced modules are now referenced by `.` rather than `/`.
|
11
36
|
|
12
37
|
## Installation
|
13
38
|
|
data/lib/enum_help/i18n.rb
CHANGED
@@ -28,7 +28,7 @@ module EnumHelp
|
|
28
28
|
def #{attr_i18n_method_name}
|
29
29
|
enum_label = self.send(:#{attr_name})
|
30
30
|
if enum_label
|
31
|
-
::EnumHelp::Helper.translate_enum_label(
|
31
|
+
::EnumHelp::Helper.translate_enum_label('#{klass}', :#{attr_name}, enum_label)
|
32
32
|
else
|
33
33
|
nil
|
34
34
|
end
|
@@ -43,7 +43,7 @@ module EnumHelp
|
|
43
43
|
klass.instance_eval <<-METHOD, __FILE__, __LINE__
|
44
44
|
def #{collection_i18n_method_name}
|
45
45
|
collection_array = #{collection_method_name}.collect do |label, _|
|
46
|
-
[label, ::EnumHelp::Helper.translate_enum_label(
|
46
|
+
[label, ::EnumHelp::Helper.translate_enum_label('#{klass}', :#{attr_name}, label)]
|
47
47
|
end
|
48
48
|
Hash[collection_array].with_indifferent_access
|
49
49
|
end
|
@@ -4,7 +4,7 @@ module EnumHelp
|
|
4
4
|
module SimpleForm
|
5
5
|
module BuilderExtension
|
6
6
|
|
7
|
-
def
|
7
|
+
def default_input_type(*args, &block)
|
8
8
|
att_name = (args.first || @attribute_name).to_s
|
9
9
|
options = args.last
|
10
10
|
return :enum_radio_buttons if options.is_a?(Hash) && options[:as] == :radio_buttons &&
|
@@ -13,7 +13,7 @@ module EnumHelp
|
|
13
13
|
return :enum if (options.is_a?(Hash) ? options[:as] : @options[:as]).nil? &&
|
14
14
|
is_enum_attributes?( att_name )
|
15
15
|
|
16
|
-
|
16
|
+
super
|
17
17
|
end
|
18
18
|
|
19
19
|
|
@@ -71,11 +71,10 @@ end
|
|
71
71
|
|
72
72
|
|
73
73
|
SimpleForm::FormBuilder.class_eval do
|
74
|
-
|
74
|
+
prepend EnumHelp::SimpleForm::BuilderExtension
|
75
75
|
|
76
76
|
map_type :enum, :to => EnumHelp::SimpleForm::EnumInput
|
77
77
|
map_type :enum_radio_buttons, :to => EnumHelp::SimpleForm::EnumRadioButtons
|
78
78
|
alias_method :collection_enum_radio_buttons, :collection_radio_buttons
|
79
79
|
alias_method :collection_enum, :collection_select
|
80
|
-
alias_method_chain :default_input_type, :enum
|
81
80
|
end
|
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.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lester Zhao
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03
|
11
|
+
date: 2016-11-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|