diff options
author | Emilio Tagua <miloops@gmail.com> | 2009-07-31 16:21:07 -0300 |
---|---|---|
committer | Emilio Tagua <miloops@gmail.com> | 2009-07-31 16:21:07 -0300 |
commit | 3de59e916d6a3d4eab202cf0c99b1f88905a3b43 (patch) | |
tree | def6d6a808ebe187be1f37f8a739fd786cc11f02 /activemodel/lib | |
parent | c1cbf02e3170f1004daf4a146cbc41176c2458d3 (diff) | |
parent | 62fd1d3716b4b5fd1d91cdcc77003efe80fc5a7e (diff) | |
download | rails-3de59e916d6a3d4eab202cf0c99b1f88905a3b43.tar.gz rails-3de59e916d6a3d4eab202cf0c99b1f88905a3b43.tar.bz2 rails-3de59e916d6a3d4eab202cf0c99b1f88905a3b43.zip |
Merge commit 'rails/master'
Conflicts:
activerecord/lib/active_record/associations.rb
Diffstat (limited to 'activemodel/lib')
-rw-r--r-- | activemodel/lib/active_model/naming.rb | 3 | ||||
-rw-r--r-- | activemodel/lib/active_model/serializers/xml.rb | 8 |
2 files changed, 8 insertions, 3 deletions
diff --git a/activemodel/lib/active_model/naming.rb b/activemodel/lib/active_model/naming.rb index ffb44e3824..b8c2a367b4 100644 --- a/activemodel/lib/active_model/naming.rb +++ b/activemodel/lib/active_model/naming.rb @@ -2,7 +2,7 @@ require 'active_support/inflector' module ActiveModel class Name < String - attr_reader :singular, :plural, :element, :collection, :partial_path + attr_reader :singular, :plural, :element, :collection, :partial_path, :human alias_method :cache_key, :collection def initialize(name) @@ -10,6 +10,7 @@ module ActiveModel @singular = ActiveSupport::Inflector.underscore(self).tr('/', '_').freeze @plural = ActiveSupport::Inflector.pluralize(@singular).freeze @element = ActiveSupport::Inflector.underscore(ActiveSupport::Inflector.demodulize(self)).freeze + @human = @element.gsub(/_/, " ") @collection = ActiveSupport::Inflector.tableize(self).freeze @partial_path = "#{@collection}/#{@element}".freeze end diff --git a/activemodel/lib/active_model/serializers/xml.rb b/activemodel/lib/active_model/serializers/xml.rb index 76a0e54a56..4508a39347 100644 --- a/activemodel/lib/active_model/serializers/xml.rb +++ b/activemodel/lib/active_model/serializers/xml.rb @@ -90,7 +90,7 @@ module ActiveModel end def root - root = (options[:root] || @serializable.class.to_s.underscore).to_s + root = (options[:root] || @serializable.class.model_name.singular).to_s reformat_name(root) end @@ -152,7 +152,11 @@ module ActiveModel def add_procs if procs = options.delete(:procs) [ *procs ].each do |proc| - proc.call(options) + if proc.arity > 1 + proc.call(options, @serializable) + else + proc.call(options) + end end end end |