Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

better i18n options...fixes issue #38

  • Loading branch information...
commit 061650c4dfff87c45fe94814625f311d81032513 1 parent 6426fd9
Marcos Piccinini authored November 23, 2012
7  lib/symbolize/mongoid.rb
@@ -54,9 +54,10 @@ def symbolize *attr_names
54 54
         configuration.update(attr_names.extract_options!)
55 55
 
56 56
         enum = configuration[:in] || configuration[:within]
57  
-        i18n = configuration.delete(:i18n).nil? && !enum.instance_of?(Hash) ? true : configuration[:i18n]
58  
-        scopes  = configuration.delete :scopes
59  
-        methods = configuration.delete :methods
  57
+        i18n = configuration.delete(:i18n)
  58
+        i18n = (!enum.instance_of?(Hash) && enum) if i18n.nil?
  59
+        scopes      = configuration.delete :scopes
  60
+        methods     = configuration.delete :methods
60 61
         capitalize  = configuration.delete :capitalize
61 62
         validation  = configuration.delete(:validate) != false
62 63
         field_type  = configuration.delete :type
6  spec/symbolize/mongoid_spec.rb
@@ -11,7 +11,7 @@ class Person
11 11
   symbolize :other, :i18n => false
12 12
 
13 13
   symbolize :language, :in => [:pt, :en]
14  
-  symbolize :sex, :type => Boolean, :scopes => true
  14
+  symbolize :sex, :type => Boolean, :scopes => true, :i18n => true
15 15
   symbolize :status , :in => [:active, :inactive], :i18n => false, :capitalize => true, :scopes => true
16 16
   symbolize :so, :allow_blank => true, :in => {
17 17
     :linux => 'Linux',
@@ -261,6 +261,10 @@ class Project
261 261
         person.sex_text.should == "Masculino"
262 262
       end
263 263
 
  264
+      it "should use i18n if i18n => true" do
  265
+        person.sex_text.should eql("Feminino")
  266
+      end
  267
+
264 268
     end
265 269
 
266 270
     describe "Methods" do
8  spec/symbolize_spec.rb
... ...
@@ -1,8 +0,0 @@
1  
-# -*- coding: utf-8 -*-
2  
-require File.dirname(__FILE__) + '/spec_helper'
3  
-
4  
-
5  
-describe "Symbolize" do
6  
-
7  
-
8  
-end

0 notes on commit 061650c

Please sign in to comment.
Something went wrong with that request. Please try again.