Merge pull request #79 from teeparham/remove-hash-check

remove unncessary is_a?(Hash) check
This commit is contained in:
José Valim 2012-06-12 10:42:30 -07:00
commit 09fac61b0a
2 changed files with 2 additions and 4 deletions

View File

@ -53,9 +53,7 @@ module ActiveModel
@options[:unique_values] = {} @options[:unique_values] = {}
array = serializable_array.map do |item| array = serializable_array.map do |item|
if item.is_a?(Hash) if item.respond_to?(:serializable_hash)
item
elsif item.respond_to?(:serializable_hash)
item.serializable_hash item.serializable_hash
else else
item.as_json item.as_json

View File

@ -408,7 +408,7 @@ class SerializerTest < ActiveModel::TestCase
hash = {:value => "something"} hash = {:value => "something"}
array = [hash] array = [hash]
serializer = array.active_model_serializer.new(array, :root => :items) serializer = array.active_model_serializer.new(array, :root => :items)
assert_equal({ :items => [ hash ]}, serializer.as_json) assert_equal({ :items => [ hash.as_json ]}, serializer.as_json)
end end
class CustomBlog < Blog class CustomBlog < Blog