lib/mongoid/i18n.rb in mongoid_i18n-0.1.7 vs lib/mongoid/i18n.rb in mongoid_i18n-0.1.8
- old
+ new
@@ -18,15 +18,15 @@
protected
def create_accessors(name, meth, options = {})
if options[:type] == LocalizedField
define_method(meth) { read_attribute(name)[::I18n.locale.to_s] rescue '' }
define_method("#{meth}=") do |value|
- if value.is_a?(Hash)
- val = (@attributes[name] || {}).merge(value)
+ value = if value.is_a?(Hash)
+ (@attributes[name] || {}).merge(value)
else
- val = (@attributes[name] || {}).merge(::I18n.locale.to_s => value)
+ (@attributes[name] || {}).merge(::I18n.locale.to_s => value)
end
- write_attribute(name, val)
+ write_attribute(name, value)
end
define_method("#{meth}_translations") { read_attribute(name) }
define_method("#{meth}_translations=") { |value| write_attribute(name, value) }
else
super
\ No newline at end of file