diff options
Diffstat (limited to 'activemodel/lib/active_model')
| -rw-r--r-- | activemodel/lib/active_model/conversion.rb | 4 | ||||
| -rw-r--r-- | activemodel/lib/active_model/naming.rb | 1 | ||||
| -rw-r--r-- | activemodel/lib/active_model/serialization.rb | 16 | 
3 files changed, 8 insertions, 13 deletions
diff --git a/activemodel/lib/active_model/conversion.rb b/activemodel/lib/active_model/conversion.rb index c7c805f1a2..d7f30f0920 100644 --- a/activemodel/lib/active_model/conversion.rb +++ b/activemodel/lib/active_model/conversion.rb @@ -21,7 +21,7 @@ module ActiveModel    #   cm.to_model == self # => true    #   cm.to_key           # => nil    #   cm.to_param         # => nil -  #   cm.to_path          # => "contact_messages/contact_message" +  #   cm.to_partial_path  # => "contact_messages/contact_message"    #    module Conversion      extend ActiveSupport::Concern @@ -57,7 +57,7 @@ module ActiveModel      end      module ClassMethods #:nodoc: -      # Provide a class level cache for the to_path. This is an +      # Provide a class level cache for #to_partial_path. This is an        # internal method and should not be accessed directly.        def _to_partial_path #:nodoc:          @_to_partial_path ||= begin diff --git a/activemodel/lib/active_model/naming.rb b/activemodel/lib/active_model/naming.rb index 755e54efcd..fd0bc4e8e9 100644 --- a/activemodel/lib/active_model/naming.rb +++ b/activemodel/lib/active_model/naming.rb @@ -2,6 +2,7 @@ require 'active_support/inflector'  require 'active_support/core_ext/hash/except'  require 'active_support/core_ext/module/introspection'  require 'active_support/core_ext/module/deprecation' +require 'active_support/core_ext/object/blank'  module ActiveModel    class Name < String diff --git a/activemodel/lib/active_model/serialization.rb b/activemodel/lib/active_model/serialization.rb index 51f078e662..4323ee1e09 100644 --- a/activemodel/lib/active_model/serialization.rb +++ b/activemodel/lib/active_model/serialization.rb @@ -1,7 +1,5 @@  require 'active_support/core_ext/hash/except'  require 'active_support/core_ext/hash/slice' -require 'active_support/core_ext/array/wrap' -  module ActiveModel    # == Active Model Serialization @@ -11,7 +9,6 @@ module ActiveModel    # A minimal implementation could be:    #    #   class Person -  #    #     include ActiveModel::Serialization    #    #     attr_accessor :name @@ -19,7 +16,6 @@ module ActiveModel    #     def attributes    #       {'name' => nil}    #     end -  #    #   end    #    # Which would provide you with: @@ -43,7 +39,6 @@ module ActiveModel    # So a minimal implementation including XML and JSON would be:    #    #   class Person -  #    #     include ActiveModel::Serializers::JSON    #     include ActiveModel::Serializers::Xml    # @@ -52,7 +47,6 @@ module ActiveModel    #     def attributes    #       {'name' => nil}    #     end -  #    #   end    #    # Which would provide you with: @@ -88,7 +82,7 @@ module ActiveModel        method_names.each { |n| hash[n.to_s] = send(n) }        serializable_add_includes(options) do |association, records, opts| -        hash[association] = if records.is_a?(Enumerable) +        hash[association.to_s] = if records.is_a?(Enumerable)            records.map { |a| a.serializable_hash(opts) }          else            records.serializable_hash(opts) @@ -126,13 +120,13 @@ module ActiveModel        #   +records+     - the association record(s) to be serialized        #   +opts+        - options for the association records        def serializable_add_includes(options = {}) #:nodoc: -        return unless include = options[:include] +        return unless includes = options[:include] -        unless include.is_a?(Hash) -          include = Hash[Array.wrap(include).map { |n| n.is_a?(Hash) ? n.to_a.first : [n, {}] }] +        unless includes.is_a?(Hash) +          includes = Hash[Array(includes).map { |n| n.is_a?(Hash) ? n.to_a.first : [n, {}] }]          end -        include.each do |association, opts| +        includes.each do |association, opts|            if records = send(association)              yield association, records, opts            end  | 
