Permalink
Browse files

better i18n options...fixes issue #38

  • Loading branch information...
nofxx committed Nov 23, 2012
1 parent 6426fd9 commit 061650c4dfff87c45fe94814625f311d81032513
Showing with 9 additions and 12 deletions.
  1. +4 −3 lib/symbolize/mongoid.rb
  2. +5 −1 spec/symbolize/mongoid_spec.rb
  3. +0 −8 spec/symbolize_spec.rb
View
@@ -54,9 +54,10 @@ def symbolize *attr_names
configuration.update(attr_names.extract_options!)
enum = configuration[:in] || configuration[:within]
- i18n = configuration.delete(:i18n).nil? && !enum.instance_of?(Hash) ? true : configuration[:i18n]
- scopes = configuration.delete :scopes
- methods = configuration.delete :methods
+ i18n = configuration.delete(:i18n)
+ i18n = (!enum.instance_of?(Hash) && enum) if i18n.nil?
+ scopes = configuration.delete :scopes
+ methods = configuration.delete :methods
capitalize = configuration.delete :capitalize
validation = configuration.delete(:validate) != false
field_type = configuration.delete :type
@@ -11,7 +11,7 @@ class Person
symbolize :other, :i18n => false
symbolize :language, :in => [:pt, :en]
- symbolize :sex, :type => Boolean, :scopes => true
+ symbolize :sex, :type => Boolean, :scopes => true, :i18n => true
symbolize :status , :in => [:active, :inactive], :i18n => false, :capitalize => true, :scopes => true
symbolize :so, :allow_blank => true, :in => {
:linux => 'Linux',
@@ -261,6 +261,10 @@ class Project
person.sex_text.should == "Masculino"
end
+ it "should use i18n if i18n => true" do
+ person.sex_text.should eql("Feminino")
+ end
+
end
describe "Methods" do
View
@@ -1,8 +0,0 @@
-# -*- coding: utf-8 -*-
-require File.dirname(__FILE__) + '/spec_helper'
-
-
-describe "Symbolize" do
-
-
-end

0 comments on commit 061650c

Please sign in to comment.