lib/enum_help/i18n.rb in enum_help-0.0.11 vs lib/enum_help/i18n.rb in enum_help-0.0.12
- old
+ new
@@ -40,12 +40,13 @@
collection_method_name = "#{attr_name.to_s.pluralize}"
collection_i18n_method_name = "#{collection_method_name}_i18n"
klass.instance_eval <<-METHOD, __FILE__, __LINE__
def #{collection_i18n_method_name}
- #{collection_method_name}.collect do |label, _|
+ collection_array = #{collection_method_name}.collect do |label, _|
[label, ::EnumHelp::Helper.translate_enum_label(self, :#{attr_name}, label)]
- end.to_h.with_indifferent_access
+ end
+ Hash[collection_array].with_indifferent_access
end
METHOD
end
def self.translate_enum_label(klass, attr_name, enum_label)