lib/mongoid/fields.rb in mongoid-1.0.6 vs lib/mongoid/fields.rb in mongoid-1.1.0

- old
+ new

@@ -6,12 +6,12 @@ extend ClassMethods # Set up the class attributes that must be available to all subclasses. # These include defaults, fields class_inheritable_accessor :defaults, :fields - self.defaults = {}.with_indifferent_access - self.fields = {}.with_indifferent_access + self.defaults = {} + self.fields = {} delegate :defaults, :fields, :to => "self.class" end end @@ -27,18 +27,19 @@ # # Example: # # <tt>field :score, :default => 0</tt> def field(name, options = {}) - set_field(name, options) - set_default(name, options) + access = name.to_s + set_field(access, options) + set_default(access, options) end protected # Define a field attribute for the +Document+. def set_field(name, options = {}) meth = options.delete(:as) || name - fields[name] = Field.new(name.to_s, options) + fields[name] = Field.new(name, options) create_accessors(name, meth, options) end # Create the field accessors. def create_accessors(name, meth, options = {})